mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
parent
2243c2e206
commit
15f8de8460
2 changed files with 0 additions and 136 deletions
|
|
@ -1,99 +0,0 @@
|
||||||
// Copyright 2017 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package vm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math/big"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"github.com/holiman/uint256"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestOpChainID(t *testing.T) {
|
|
||||||
pc := uint64(1)
|
|
||||||
evm := EVM{}
|
|
||||||
chainID := big.NewInt(1)
|
|
||||||
chainConfig := params.ChainConfig{ChainID: chainID}
|
|
||||||
evm.chainConfig = &chainConfig
|
|
||||||
interpreter := EVMInterpreter{evm: &evm}
|
|
||||||
stack := Stack{}
|
|
||||||
scope := ScopeContext{Stack: &stack}
|
|
||||||
_, ret2 := opChainID(&pc, &interpreter, &scope)
|
|
||||||
if ret2 != nil || len(stack.data) != 1 || stack.data[0] != *uint256.NewInt(1) {
|
|
||||||
t.Errorf("opChainID not successful")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestOpBaseFee(t *testing.T) {
|
|
||||||
pc := uint64(1)
|
|
||||||
baseFee := big.NewInt(1)
|
|
||||||
context := BlockContext{BaseFee: baseFee}
|
|
||||||
evm := EVM{Context: context}
|
|
||||||
interpreter := EVMInterpreter{evm: &evm}
|
|
||||||
stack := Stack{}
|
|
||||||
scope := ScopeContext{Stack: &stack}
|
|
||||||
_, ret2 := opBaseFee(&pc, &interpreter, &scope)
|
|
||||||
if ret2 != nil || len(stack.data) != 1 || stack.data[0] != *uint256.NewInt(1) {
|
|
||||||
t.Errorf("opBaseFee not successful")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestOpBlobBaseFee(t *testing.T) {
|
|
||||||
pc := uint64(1)
|
|
||||||
blobBaseFee := big.NewInt(1)
|
|
||||||
context := BlockContext{BlobBaseFee: blobBaseFee}
|
|
||||||
evm := EVM{Context: context}
|
|
||||||
interpreter := EVMInterpreter{evm: &evm}
|
|
||||||
stack := Stack{}
|
|
||||||
scope := ScopeContext{Stack: &stack}
|
|
||||||
_, ret2 := opBlobBaseFee(&pc, &interpreter, &scope)
|
|
||||||
if ret2 != nil || len(stack.data) != 1 || stack.data[0] != *uint256.NewInt(1) {
|
|
||||||
t.Errorf("opBlobBaseFee not successful")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestOpPush1EIP4762(t *testing.T) {
|
|
||||||
pc := uint64(1)
|
|
||||||
context := BlockContext{}
|
|
||||||
evm := EVM{Context: context}
|
|
||||||
interpreter := EVMInterpreter{evm: &evm}
|
|
||||||
contract := Contract{Code: []byte{0, 1, 2}}
|
|
||||||
stack := Stack{}
|
|
||||||
scope := ScopeContext{Contract: &contract, Stack: &stack}
|
|
||||||
_, ret2 := opPush1EIP4762(&pc, &interpreter, &scope)
|
|
||||||
if ret2 != nil || len(stack.data) != 1 || stack.data[0] != *uint256.NewInt(2) {
|
|
||||||
t.Errorf("opPush1EIP4762 not successful")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMakePushEIP4762(t *testing.T) {
|
|
||||||
ef := makePushEIP4762(4, 8)
|
|
||||||
|
|
||||||
pc := uint64(1)
|
|
||||||
context := BlockContext{}
|
|
||||||
evm := EVM{Context: context}
|
|
||||||
interpreter := EVMInterpreter{evm: &evm}
|
|
||||||
contract := Contract{Code: []byte{0, 1, 2}, IsDeployment: true}
|
|
||||||
stack := Stack{}
|
|
||||||
scope := ScopeContext{Contract: &contract, Stack: &stack}
|
|
||||||
|
|
||||||
_, ret2 := ef(&pc, &interpreter, &scope)
|
|
||||||
if ret2 != nil || len(stack.data) != 1 || pc != uint64(5) {
|
|
||||||
t.Errorf("makePushEIP4762 not successful")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
// Copyright 2017 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package vm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/holiman/uint256"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestCallGas(t *testing.T) {
|
|
||||||
availableGas := uint64(100)
|
|
||||||
base := uint64(50)
|
|
||||||
callCost := uint256.NewInt(70)
|
|
||||||
ret1, ret2 := callGas(false, availableGas, base, callCost)
|
|
||||||
if ret2 != nil || ret1 != uint64(70) {
|
|
||||||
t.Errorf("callGas not successful")
|
|
||||||
}
|
|
||||||
ret1, ret2 = callGas(true, availableGas, base, callCost)
|
|
||||||
if ret2 != nil || ret1 != uint64(50) {
|
|
||||||
t.Errorf("callGas not successful")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue