From 604dd7e52c8cbffd7646205c464f7333d215ceb6 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Thu, 4 Oct 2018 17:19:28 +0800 Subject: core: Check sorted ack in sanity check (#173) --- core/lattice_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'core/lattice_test.go') diff --git a/core/lattice_test.go b/core/lattice_test.go index 2115d1a..bf65684 100644 --- a/core/lattice_test.go +++ b/core/lattice_test.go @@ -220,6 +220,17 @@ func (s *LatticeTestSuite) TestSanityCheck() { b.Signature, err = auth.prvKey.Sign(common.NewRandomHash()) req.NoError(err) req.Equal(lattice.SanityCheck(b), ErrIncorrectSignature) + // A block with un-sorted acks should not pass sanity check. + b.Acks = common.NewSortedHashes(common.Hashes{ + common.NewRandomHash(), + common.NewRandomHash(), + common.NewRandomHash(), + common.NewRandomHash(), + common.NewRandomHash(), + }) + b.Acks[0], b.Acks[1] = b.Acks[1], b.Acks[0] + req.NoError(auth.SignBlock(b)) + req.Equal(lattice.SanityCheck(b), ErrAcksNotSorted) // A block with incorrect hash should not pass sanity check. b.Hash = common.NewRandomHash() req.Equal(lattice.SanityCheck(b), ErrIncorrectHash) -- cgit v1.2.3