mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
core/types: update deposit test
This commit is contained in:
parent
89a441f187
commit
8735cf3649
1 changed files with 13 additions and 13 deletions
|
|
@ -17,8 +17,7 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"bytes"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
|
|
@ -71,23 +70,24 @@ func FuzzUnpackIntoDeposit(f *testing.F) {
|
||||||
copy(sig[:], s)
|
copy(sig[:], s)
|
||||||
copy(index[:], i)
|
copy(index[:], i)
|
||||||
|
|
||||||
want := Deposit{
|
var enc []byte
|
||||||
PublicKey: pubkey,
|
enc = append(enc, depositRequestType)
|
||||||
WithdrawalCredentials: wxCred,
|
enc = append(enc, pubkey[:]...)
|
||||||
Amount: binary.LittleEndian.Uint64(amount[:]),
|
enc = append(enc, wxCred[:]...)
|
||||||
Signature: sig,
|
enc = append(enc, amount[:]...)
|
||||||
Index: binary.LittleEndian.Uint64(index[:]),
|
enc = append(enc, sig[:]...)
|
||||||
}
|
enc = append(enc, index[:]...)
|
||||||
out, err := depositABI.Pack("DepositEvent", want.PublicKey[:], want.WithdrawalCredentials[:], amount[:], want.Signature[:], index[:])
|
|
||||||
|
out, err := depositABI.Pack("DepositEvent", pubkey[:], wxCred[:], amount[:], sig[:], index[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error packing deposit: %v", err)
|
t.Fatalf("error packing deposit: %v", err)
|
||||||
}
|
}
|
||||||
got, err := UnpackIntoDeposit(out[4:])
|
got, err := DepositLogToRequest(out[4:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error unpacking deposit: %v", err)
|
t.Errorf("error unpacking deposit: %v", err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(want, *got) {
|
if !bytes.Equal(enc, got) {
|
||||||
t.Errorf("roundtrip failed: want %v, got %v", want, got)
|
t.Errorf("roundtrip failed: want %x, got %x", enc, got)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue