MCPcopy Create free account
hub / github.com/CPChain/chain / TestStoreCapture

Function TestStoreCapture

core/vm/logger_test.go:49–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestStoreCapture(t *testing.T) {
50 var (
51 env = NewEVM(Context{}, nil, configs.TestChainConfig, Config{})
52 logger = NewStructLogger(nil)
53 mem = NewMemory()
54 stack = newstack()
55 contract = NewContract(&dummyContractRef{}, &dummyContractRef{}, new(big.Int), 0)
56 )
57 stack.push(big.NewInt(1))
58 stack.push(big.NewInt(0))
59
60 var index common.Hash
61
62 logger.CaptureState(env, 0, SSTORE, 0, 0, mem, stack, contract, 0, nil)
63 if len(logger.changedValues[contract.Address()]) == 0 {
64 t.Fatalf("expected exactly 1 changed value on address %x, got %d", contract.Address(), len(logger.changedValues[contract.Address()]))
65 }
66 exp := common.BigToHash(big.NewInt(1))
67 if logger.changedValues[contract.Address()][index] != exp {
68 t.Errorf("expected %x, got %x", exp, logger.changedValues[contract.Address()][index])
69 }
70}

Callers

nothing calls this directly

Calls 8

NewEVMFunction · 0.85
NewStructLoggerFunction · 0.85
NewMemoryFunction · 0.85
newstackFunction · 0.85
NewContractFunction · 0.85
CaptureStateMethod · 0.65
AddressMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected