@@ -41,6 +41,12 @@ func TestGenesisContractChange(t *testing.T) {
4141 "balance" : "0x1000" ,
4242 },
4343 },
44+ "6" : map [string ]interface {}{
45+ addr0 .Hex (): map [string ]interface {}{
46+ "code" : hexutil.Bytes {0x1 , 0x4 },
47+ "balance" : "0x2000" ,
48+ },
49+ },
4450 },
4551 },
4652 }
@@ -87,24 +93,35 @@ func TestGenesisContractChange(t *testing.T) {
8793
8894 root := genesis .Root ()
8995
90- // code does not change
96+ // code does not change, balance remains 0
9197 root , statedb = addBlock (root , 1 )
9298 require .Equal (t , statedb .GetCode (addr0 ), []byte {0x1 , 0x1 })
99+ require .Equal (t , statedb .GetBalance (addr0 ), big .NewInt (0 ))
93100
94- // code changes 1st time
101+ // code changes 1st time, balance remains 0
95102 root , statedb = addBlock (root , 2 )
96103 require .Equal (t , statedb .GetCode (addr0 ), []byte {0x1 , 0x2 })
104+ require .Equal (t , statedb .GetBalance (addr0 ), big .NewInt (0 ))
97105
98- // code same as 1st change
106+ // code same as 1st change, balance remains 0
99107 root , statedb = addBlock (root , 3 )
100108 require .Equal (t , statedb .GetCode (addr0 ), []byte {0x1 , 0x2 })
109+ require .Equal (t , statedb .GetBalance (addr0 ), big .NewInt (0 ))
101110
102- // code changes 2nd time
103- _ , statedb = addBlock (root , 4 )
111+ // code changes 2nd time, balance updates to 4096
112+ root , statedb = addBlock (root , 4 )
104113 require .Equal (t , statedb .GetCode (addr0 ), []byte {0x1 , 0x3 })
114+ require .Equal (t , statedb .GetBalance (addr0 ), big .NewInt (4096 ))
105115
106- // make sure balance change DOES NOT take effect
107- require .Equal (t , statedb .GetBalance (addr0 ), big .NewInt (0 ))
116+ // code same as 2nd change, balance remains 4096
117+ root , statedb = addBlock (root , 5 )
118+ require .Equal (t , statedb .GetCode (addr0 ), []byte {0x1 , 0x3 })
119+ require .Equal (t , statedb .GetBalance (addr0 ), big .NewInt (4096 ))
120+
121+ // code changes 3rd time, balance remains 4096
122+ _ , statedb = addBlock (root , 6 )
123+ require .Equal (t , statedb .GetCode (addr0 ), []byte {0x1 , 0x4 })
124+ require .Equal (t , statedb .GetBalance (addr0 ), big .NewInt (4096 ))
108125}
109126
110127func TestEncodeSigHeaderJaipur (t * testing.T ) {
0 commit comments