Skip to content

Commit 200f665

Browse files
committed
updated tests
1 parent 0823254 commit 200f665

2 files changed

Lines changed: 30 additions & 18 deletions

File tree

‎tests/vm/gh_test.go‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ func RunVmTest(p string, t *testing.T) {
7979
helper.CreateFileTests(t, p, &tests)
8080

8181
for name, test := range tests {
82-
helper.Logger.SetLogLevel(4)
83-
if name != "TransactionNonceCheck2" {
84-
continue
85-
}
82+
/*
83+
helper.Logger.SetLogLevel(4)
84+
if name != "log1_nonEmptyMem_logMemSize1_logMemStart31" {
85+
continue
86+
}
87+
*/
8688
db, _ := ethdb.NewMemDatabase()
8789
statedb := state.New(nil, db)
8890
for addr, account := range test.Pre {
@@ -159,10 +161,14 @@ func RunVmTest(p string, t *testing.T) {
159161
}
160162

161163
if len(test.Logs) > 0 {
162-
for i, log := range test.Logs {
163-
genBloom := ethutil.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 64)
164-
if !bytes.Equal(genBloom, ethutil.Hex2Bytes(log.BloomF)) {
165-
t.Errorf("bloom mismatch")
164+
if len(test.Logs) != len(logs) {
165+
t.Errorf("log length mismatch. Expected %d, got %d", len(test.Logs), len(logs))
166+
} else {
167+
for i, log := range test.Logs {
168+
genBloom := ethutil.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 64)
169+
if !bytes.Equal(genBloom, ethutil.Hex2Bytes(log.BloomF)) {
170+
t.Errorf("bloom mismatch")
171+
}
166172
}
167173
}
168174
}
@@ -176,11 +182,6 @@ func TestVMArithmetic(t *testing.T) {
176182
RunVmTest(fn, t)
177183
}
178184

179-
func TestSystemOperations(t *testing.T) {
180-
const fn = "../files/VMTests/vmSystemOperationsTest.json"
181-
RunVmTest(fn, t)
182-
}
183-
184185
func TestBitwiseLogicOperation(t *testing.T) {
185186
const fn = "../files/VMTests/vmBitwiseLogicOperationTest.json"
186187
RunVmTest(fn, t)
@@ -201,6 +202,17 @@ func TestFlowOperation(t *testing.T) {
201202
RunVmTest(fn, t)
202203
}
203204

205+
func TestLogTest(t *testing.T) {
206+
const fn = "../files/VMTests/vmLogTest.json"
207+
RunVmTest(fn, t)
208+
}
209+
210+
func TestPerformance(t *testing.T) {
211+
t.Skip()
212+
const fn = "../files/VMTests/vmPerformance.json"
213+
RunVmTest(fn, t)
214+
}
215+
204216
func TestPushDupSwap(t *testing.T) {
205217
const fn = "../files/VMTests/vmPushDupSwapTest.json"
206218
RunVmTest(fn, t)

‎vm/vm.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func New(env Environment) *Vm {
3434
lt = LogTyDiff
3535
}
3636

37-
return &Vm{debug: false, env: env, logTy: lt, Recoverable: true}
37+
return &Vm{debug: true, env: env, logTy: lt, Recoverable: true}
3838
}
3939

4040
func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
@@ -56,8 +56,6 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
5656

5757
err = fmt.Errorf("%v", r)
5858

59-
} else {
60-
fmt.Println(me.(*state.StateObject).Storage())
6159
}
6260
}()
6361
}
@@ -668,7 +666,6 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
668666
}
669667
addr = ref.Address()
670668

671-
fmt.Printf("CREATE %X\n", addr)
672669
stack.Push(ethutil.BigD(addr))
673670

674671
}
@@ -860,6 +857,8 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
860857

861858
// Stack Check, memory resize & gas phase
862859
switch op {
860+
case PUSH1, PUSH2, PUSH3, PUSH4, PUSH5, PUSH6, PUSH7, PUSH8, PUSH9, PUSH10, PUSH11, PUSH12, PUSH13, PUSH14, PUSH15, PUSH16, PUSH17, PUSH18, PUSH19, PUSH20, PUSH21, PUSH22, PUSH23, PUSH24, PUSH25, PUSH26, PUSH27, PUSH28, PUSH29, PUSH30, PUSH31, PUSH32:
861+
gas.Set(GasFastestStep)
863862
case SWAP1, SWAP2, SWAP3, SWAP4, SWAP5, SWAP6, SWAP7, SWAP8, SWAP9, SWAP10, SWAP11, SWAP12, SWAP13, SWAP14, SWAP15, SWAP16:
864863
n := int(op - SWAP1 + 2)
865864
stack.require(n)
@@ -897,11 +896,12 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
897896
g = GasStorageMod
898897
}
899898
gas.Set(g)
900-
newMemSize = calcMemSize(stack.Peek(), u256(32))
901899
case MLOAD:
902900
newMemSize = calcMemSize(stack.Peek(), u256(32))
903901
case MSTORE8:
904902
newMemSize = calcMemSize(stack.Peek(), u256(1))
903+
case MSTORE:
904+
newMemSize = calcMemSize(stack.Peek(), u256(32))
905905
case RETURN:
906906
newMemSize = calcMemSize(stack.Peek(), stack.data[stack.Len()-2])
907907
case SHA3:

0 commit comments

Comments
 (0)