diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-10-25 16:59:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-25 16:59:30 +0800 |
commit | 04eeac10e6c690e62ae57ef0e2bdf4618b8782d1 (patch) | |
tree | e0b95167d1f42a9304fb9e924378464edbb517e9 /core/test/revealer_test.go | |
parent | 233f1e8de99bf2a0023f05d1c67e48cc770621df (diff) | |
download | dexon-consensus-04eeac10e6c690e62ae57ef0e2bdf4618b8782d1.tar dexon-consensus-04eeac10e6c690e62ae57ef0e2bdf4618b8782d1.tar.gz dexon-consensus-04eeac10e6c690e62ae57ef0e2bdf4618b8782d1.tar.bz2 dexon-consensus-04eeac10e6c690e62ae57ef0e2bdf4618b8782d1.tar.lz dexon-consensus-04eeac10e6c690e62ae57ef0e2bdf4618b8782d1.tar.xz dexon-consensus-04eeac10e6c690e62ae57ef0e2bdf4618b8782d1.tar.zst dexon-consensus-04eeac10e6c690e62ae57ef0e2bdf4618b8782d1.zip |
core: lattice sync (#257)
Diffstat (limited to 'core/test/revealer_test.go')
-rw-r--r-- | core/test/revealer_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/test/revealer_test.go b/core/test/revealer_test.go index 8bb46bc..4945d62 100644 --- a/core/test/revealer_test.go +++ b/core/test/revealer_test.go @@ -135,6 +135,29 @@ func (s *RevealerTestSuite) TestRandomDAGReveal() { s.baseTest(revealer, 10, checkFunc) } +func (s *RevealerTestSuite) TestRandomTipReveal() { + // This test case would make sure we could at least generate + // two different revealing sequence when revealing more than + // 10 times. + iter, err := s.db.GetAll() + s.Require().Nil(err) + revealer, err := NewRandomTipRevealer(iter) + s.Require().Nil(err) + + checkFunc := func(b *types.Block, revealed map[common.Hash]struct{}) { + // Make sure the revealer won't reveal the same block twice. + _, alreadyRevealed := revealed[b.Hash] + s.False(alreadyRevealed) + // Make sure the parent is already revealed. + if b.Position.Height == 0 { + return + } + _, alreadyRevealed = revealed[b.ParentHash] + s.True(alreadyRevealed) + } + s.baseTest(revealer, 10, checkFunc) +} + func TestRevealer(t *testing.T) { suite.Run(t, new(RevealerTestSuite)) } |