Skip to content

Commit

Permalink
check commit for test devnet (#2395)
Browse files Browse the repository at this point in the history
  • Loading branch information
phritz committed Mar 22, 2019
1 parent b87348b commit 29f585c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion protocol/hello/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (h *Handler) processHelloMessage(from peer.ID, msg *Message) error {
if !msg.GenesisHash.Equals(h.genesis) {
return ErrBadGenesis
}
if h.net == "devnet-user" && msg.CommitSha != h.commitSha {
if (h.net == "devnet-test" || h.net == "devnet-user") && msg.CommitSha != h.commitSha {
return ErrWrongVersion
}

Expand Down
34 changes: 34 additions & 0 deletions protocol/hello/hello_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,40 @@ func TestHelloWrongVersion(t *testing.T) {
msc2.AssertNumberOfCalls(t, "SyncCallback", 0)
}

func TestHelloWrongVersionTestDevnet(t *testing.T) {
t.Parallel()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
require := require.New(t)

mn, err := mocknet.WithNPeers(ctx, 2)
assert.NoError(t, err)

a, b := mn.Hosts()[0], mn.Hosts()[1]

genesisA := &types.Block{Nonce: 451}

heavy := th.RequireNewTipSet(require, &types.Block{Nonce: 1000, Height: 2})

msc1, msc2 := new(mockSyncCallback), new(mockSyncCallback)
hg := &mockHeaviestGetter{heavy}

New(a, genesisA.Cid(), msc1.SyncCallback, hg.getHeaviestTipSet, "devnet-test", "sha1")
msc1.On("SyncCallback", mock.Anything, mock.Anything, mock.Anything).Return()

New(b, genesisA.Cid(), msc2.SyncCallback, hg.getHeaviestTipSet, "devnet-test", "sha2")
msc2.On("SyncCallback", mock.Anything, mock.Anything, mock.Anything).Return()

require.NoError(mn.LinkAll())
require.NoError(mn.ConnectAllButSelf())

time.Sleep(time.Millisecond * 50)

msc1.AssertNumberOfCalls(t, "SyncCallback", 0)
msc2.AssertNumberOfCalls(t, "SyncCallback", 0)
}

func TestHelloMultiBlock(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 29f585c

Please sign in to comment.