github.com/dim4egster/coreth@v0.10.2/core/stateful_precompile_test.go (about) 1 // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package core 5 6 import ( 7 "math/big" 8 9 "github.com/dim4egster/coreth/core/state" 10 "github.com/dim4egster/coreth/precompile" 11 "github.com/ethereum/go-ethereum/common" 12 ) 13 14 var ( 15 _ precompile.BlockContext = &mockBlockContext{} 16 _ precompile.PrecompileAccessibleState = &mockAccessibleState{} 17 ) 18 19 type mockBlockContext struct { 20 blockNumber *big.Int 21 timestamp uint64 22 } 23 24 func (mb *mockBlockContext) Number() *big.Int { return mb.blockNumber } 25 func (mb *mockBlockContext) Timestamp() *big.Int { return new(big.Int).SetUint64(mb.timestamp) } 26 27 type mockAccessibleState struct { 28 state *state.StateDB 29 blockContext *mockBlockContext 30 31 // NativeAssetCall return values 32 ret []byte 33 remainingGas uint64 34 err error 35 } 36 37 func (m *mockAccessibleState) GetStateDB() precompile.StateDB { return m.state } 38 39 func (m *mockAccessibleState) GetBlockContext() precompile.BlockContext { return m.blockContext } 40 41 func (m *mockAccessibleState) NativeAssetCall(common.Address, []byte, uint64, uint64, bool) ([]byte, uint64, error) { 42 return m.ret, m.remainingGas, m.err 43 }