99
1010 "github.com/ava-labs/libevm/common"
1111 "github.com/ava-labs/libevm/core/types"
12- "github.com/stretchr/testify/assert "
12+ "github.com/stretchr/testify/require "
1313)
1414
1515// Default state history size
@@ -42,7 +42,6 @@ func TestCappedMemoryTrieWriter(t *testing.T) {
4242 m := & MockTrieDB {}
4343 cacheConfig := & CacheConfig {Pruning : true , CommitInterval : 4096 , StateHistory : uint64 (tipBufferSize )}
4444 w := NewTrieWriter (m , cacheConfig )
45- assert := assert .New (t )
4645 for i := 0 ; i < int (cacheConfig .CommitInterval )+ 1 ; i ++ {
4746 bigI := big .NewInt (int64 (i ))
4847 block := types .NewBlock (
@@ -53,35 +52,34 @@ func TestCappedMemoryTrieWriter(t *testing.T) {
5352 nil , nil , nil , nil ,
5453 )
5554
56- assert .NoError (w .InsertTrie (block ))
57- assert . Equal (common. Hash {} , m .LastDereference , "should not have dereferenced block on insert" )
58- assert . Equal (common. Hash {} , m .LastCommit , "should not have committed block on insert" )
55+ require .NoError (t , w .InsertTrie (block ))
56+ require . Zero ( t , m .LastDereference , "should not have dereferenced block on insert" )
57+ require . Zero ( t , m .LastCommit , "should not have committed block on insert" )
5958
6059 w .AcceptTrie (block )
6160 if i <= tipBufferSize {
62- assert . Equal (common. Hash {} , m .LastDereference , "should not have dereferenced block on accept" )
61+ require . Zero ( t , m .LastDereference , "should not have dereferenced block on accept" )
6362 } else {
64- assert .Equal (common .BigToHash (big .NewInt (int64 (i - tipBufferSize ))), m .LastDereference , "should have dereferenced old block on last accept" )
63+ require .Equal (t , common .BigToHash (big .NewInt (int64 (i - tipBufferSize ))), m .LastDereference , "should have dereferenced old block on last accept" )
6564 m .LastDereference = common.Hash {}
6665 }
6766 if i < int (cacheConfig .CommitInterval ) {
68- assert . Equal (common. Hash {} , m .LastCommit , "should not have committed block on accept" )
67+ require . Zero ( t , m .LastCommit , "should not have committed block on accept" )
6968 } else {
70- assert .Equal (block .Root (), m .LastCommit , "should have committed block after CommitInterval" )
69+ require .Equal (t , block .Root (), m .LastCommit , "should have committed block after CommitInterval" )
7170 m .LastCommit = common.Hash {}
7271 }
7372
7473 w .RejectTrie (block )
75- assert .Equal (block .Root (), m .LastDereference , "should have dereferenced block on reject" )
76- assert . Equal (common. Hash {} , m .LastCommit , "should not have committed block on reject" )
74+ require .Equal (t , block .Root (), m .LastDereference , "should have dereferenced block on reject" )
75+ require . Zero ( t , m .LastCommit , "should not have committed block on reject" )
7776 m .LastDereference = common.Hash {}
7877 }
7978}
8079
8180func TestNoPruningTrieWriter (t * testing.T ) {
8281 m := & MockTrieDB {}
8382 w := NewTrieWriter (m , & CacheConfig {})
84- assert := assert .New (t )
8583 for i := 0 ; i < tipBufferSize + 1 ; i ++ {
8684 bigI := big .NewInt (int64 (i ))
8785 block := types .NewBlock (
@@ -92,18 +90,18 @@ func TestNoPruningTrieWriter(t *testing.T) {
9290 nil , nil , nil , nil ,
9391 )
9492
95- assert .NoError (w .InsertTrie (block ))
96- assert . Equal (common. Hash {} , m .LastDereference , "should not have dereferenced block on insert" )
97- assert . Equal (common. Hash {} , m .LastCommit , "should not have committed block on insert" )
93+ require .NoError (t , w .InsertTrie (block ))
94+ require . Zero ( t , m .LastDereference , "should not have dereferenced block on insert" )
95+ require . Zero ( t , m .LastCommit , "should not have committed block on insert" )
9896
9997 w .AcceptTrie (block )
100- assert . Equal (common. Hash {} , m .LastDereference , "should not have dereferenced block on accept" )
101- assert .Equal (block .Root (), m .LastCommit , "should have committed block on accept" )
98+ require . Zero ( t , m .LastDereference , "should not have dereferenced block on accept" )
99+ require .Equal (t , block .Root (), m .LastCommit , "should have committed block on accept" )
102100 m .LastCommit = common.Hash {}
103101
104102 w .RejectTrie (block )
105- assert .Equal (block .Root (), m .LastDereference , "should have dereferenced block on reject" )
106- assert . Equal (common. Hash {} , m .LastCommit , "should not have committed block on reject" )
103+ require .Equal (t , block .Root (), m .LastDereference , "should have dereferenced block on reject" )
104+ require . Zero ( t , m .LastCommit , "should not have committed block on reject" )
107105 m .LastDereference = common.Hash {}
108106 }
109107}
0 commit comments