Skip to content

Commit

Permalink
int
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Kim <[email protected]>
  • Loading branch information
joshua-kim committed Dec 6, 2023
1 parent 587bc26 commit 41185a2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/DataDog/zstd v1.5.2
github.com/Microsoft/go-winio v0.5.2
github.com/NYTimes/gziphandler v1.1.1
github.com/ava-labs/coreth v0.12.10-rc.0
github.com/ava-labs/coreth v0.12.9-rc.6.0.20231206185214-891ed824c9f9
github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/coreth v0.12.9-rc.6.0.20231206185214-891ed824c9f9 h1:7XHNi4RPyFF6Pu/spRd3z/hJgsrbxoJ2RV2wtx9TZAM=
github.com/ava-labs/coreth v0.12.9-rc.6.0.20231206185214-891ed824c9f9/go.mod h1:PXsfjJVVlHDjdZ9FixIGijVvL3H1GC00heExDMt6Do8=
github.com/ava-labs/coreth v0.12.10-rc.0 h1:qmuom7rtH5hc1E3lnqrMFNLFL1TMnEVa/2O8poB1YLU=
github.com/ava-labs/coreth v0.12.10-rc.0/go.mod h1:plFm/xzvWmx1+qJ3JQSTzF8+FdaA2xu7GgY/AdaZDfk=
github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34 h1:mg9Uw6oZFJKytJxgxnl3uxZOs/SB8CVHg6Io4Tf99Zc=
Expand Down
17 changes: 11 additions & 6 deletions network/p2p/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import (
"github.com/ava-labs/avalanchego/version"
)

var errFoo = &common.AppError{
Code: 123,
Message: "foo",
}

func TestAppRequestResponse(t *testing.T) {
handlerID := uint64(0x0)
request := []byte("request")
Expand Down Expand Up @@ -85,7 +90,7 @@ func TestAppRequestResponse(t *testing.T) {
sender.SendAppRequestF = func(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, request []byte) error {
for range nodeIDs {
go func() {
require.NoError(t, network.AppRequestFailed(ctx, nodeID, requestID))
require.NoError(t, network.AppRequestFailed(ctx, nodeID, requestID, errFoo))
}()
}

Expand All @@ -95,7 +100,7 @@ func TestAppRequestResponse(t *testing.T) {
callback := func(_ context.Context, actualNodeID ids.NodeID, actualResponse []byte, err error) {
defer wg.Done()

require.ErrorIs(t, err, ErrAppRequestFailed)
require.ErrorIs(t, err, errFoo)
require.Equal(t, nodeID, actualNodeID)
require.Nil(t, actualResponse)
}
Expand Down Expand Up @@ -140,14 +145,14 @@ func TestAppRequestResponse(t *testing.T) {
requestFunc: func(t *testing.T, network *Network, client *Client, sender *common.SenderTest, handler *mocks.MockHandler, wg *sync.WaitGroup) {
sender.SendCrossChainAppRequestF = func(ctx context.Context, chainID ids.ID, requestID uint32, request []byte) {
go func() {
require.NoError(t, network.CrossChainAppRequestFailed(ctx, chainID, requestID))
require.NoError(t, network.CrossChainAppRequestFailed(ctx, chainID, requestID, errFoo))
}()
}

callback := func(_ context.Context, actualChainID ids.ID, actualResponse []byte, err error) {
defer wg.Done()

require.ErrorIs(t, err, ErrAppRequestFailed)
require.ErrorIs(t, err, errFoo)
require.Equal(t, chainID, actualChainID)
require.Nil(t, actualResponse)
}
Expand Down Expand Up @@ -273,7 +278,7 @@ func TestNetworkDropMessage(t *testing.T) {
{
name: "drop unrequested app request failed",
requestFunc: func(network *Network) error {
return network.AppRequestFailed(context.Background(), ids.GenerateTestNodeID(), 0)
return network.AppRequestFailed(context.Background(), ids.GenerateTestNodeID(), 0, errFoo)
},
err: ErrUnrequestedResponse,
},
Expand All @@ -287,7 +292,7 @@ func TestNetworkDropMessage(t *testing.T) {
{
name: "drop unrequested cross-chain request failed",
requestFunc: func(network *Network) error {
return network.CrossChainAppRequestFailed(context.Background(), ids.GenerateTestID(), 0)
return network.CrossChainAppRequestFailed(context.Background(), ids.GenerateTestID(), 0, errFoo)
},
err: ErrUnrequestedResponse,
},
Expand Down
4 changes: 2 additions & 2 deletions x/sync/mock_network_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 41185a2

Please sign in to comment.