mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
core/vm: update tests
This commit is contained in:
parent
8c72226321
commit
891ae31ad2
1 changed files with 5 additions and 7 deletions
|
|
@ -974,18 +974,18 @@ func TestPush(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOpCLZ(t *testing.T) {
|
||||
// set up once
|
||||
evm := NewEVM(BlockContext{}, nil, params.TestChainConfig, Config{})
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
inputHex string // hexadecimal input for clarity
|
||||
inputHex string
|
||||
want uint64 // expected CLZ result
|
||||
}{
|
||||
{"zero", "0x0", 256},
|
||||
{"one", "0x1", 255},
|
||||
{"all-ones (256 bits)", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0},
|
||||
{"low-10-bytes ones", "0xffffffffff", 216}, // 10 bytes = 80 bits, so 256-80=176? Actually input is 0xffffffffff = 40 bits so 256-40=216
|
||||
{"low-40-bits", "0xffffffffff", 216}, // 40 bits, so 256-40 = 216
|
||||
{"low-11-bits", "0x6ff", 245}, // 0x6ff = 0b11011111111 (11 bits), so 256-11 = 245
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
|
@ -996,9 +996,8 @@ func TestOpCLZ(t *testing.T) {
|
|||
|
||||
// parse input
|
||||
val := new(uint256.Int)
|
||||
if _, err := fmt.Sscan(tc.inputHex, val); err != nil {
|
||||
// fallback: try hex
|
||||
val.SetFromHex(tc.inputHex)
|
||||
if err := val.SetFromHex(tc.inputHex); err != nil {
|
||||
t.Fatal("invalid hex uint256:", tc.inputHex)
|
||||
}
|
||||
|
||||
stack.push(val)
|
||||
|
|
@ -1008,7 +1007,6 @@ func TestOpCLZ(t *testing.T) {
|
|||
t.Fatalf("stack length = %d; want 1", gotLen)
|
||||
}
|
||||
result := stack.pop()
|
||||
|
||||
if got := result.Uint64(); got != tc.want {
|
||||
t.Fatalf("clz(%q) = %d; want %d", tc.inputHex, got, tc.want)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue