@@ -29,7 +29,10 @@ tape('StateManager', (t) => {
29
29
const getAccount = promisify ( ( ...args ) => stateManager . getAccount ( ...args ) )
30
30
const commit = promisify ( ( ...args ) => stateManager . commit ( ...args ) )
31
31
const setStateRoot = promisify ( ( ...args ) => stateManager . setStateRoot ( ...args ) )
32
+ const putContractStorage = promisify ( ( ...args ) => stateManager . putContractStorage ( ...args ) )
33
+ const getContractStorage = promisify ( ( ...args ) => stateManager . getContractStorage ( ...args ) )
32
34
35
+ // test account storage cache
33
36
const initialStateRoot = await getStateRoot ( )
34
37
await checkpoint ( )
35
38
await putAccount ( addressBuffer , account )
@@ -45,6 +48,20 @@ tape('StateManager', (t) => {
45
48
const account2 = await getAccount ( addressBuffer )
46
49
st . equal ( account2 . balance . toString ( 'hex' ) , '' , 'account value is set to 0 in original state root' )
47
50
51
+ // test contract storage cache
52
+ await checkpoint ( )
53
+ const key = Buffer . from ( '0x1234' )
54
+ const value = Buffer . from ( '0x1234' )
55
+ await putContractStorage ( addressBuffer , key , value )
56
+
57
+ const contract0 = await getContractStorage ( addressBuffer , key )
58
+ st . equal ( contract0 . toString ( 'hex' ) , value . toString ( 'hex' ) , 'contract key\'s value is set in the _storageTries cache' )
59
+
60
+ await commit ( )
61
+ await setStateRoot ( initialStateRoot )
62
+ const contract1 = await getContractStorage ( addressBuffer , key )
63
+ st . equal ( contract1 . toString ( 'hex' ) , '' , 'contract key\'s value is unset in the _storageTries cache' )
64
+
48
65
st . end ( )
49
66
} )
50
67
0 commit comments