core/types: update deposit test

Felix Lange 2 months ago
parent 03f484d78e
commit e64dfdd243
  1. 26
      core/types/deposit_test.go

@ -17,8 +17,7 @@
package types
import (
"encoding/binary"
"reflect"
"bytes"
"testing"
"github.com/ethereum/go-ethereum/accounts/abi"
@ -71,23 +70,24 @@ func FuzzUnpackIntoDeposit(f *testing.F) {
copy(sig[:], s)
copy(index[:], i)
want := Deposit{
PublicKey: pubkey,
WithdrawalCredentials: wxCred,
Amount: binary.LittleEndian.Uint64(amount[:]),
Signature: sig,
Index: binary.LittleEndian.Uint64(index[:]),
}
out, err := depositABI.Pack("DepositEvent", want.PublicKey[:], want.WithdrawalCredentials[:], amount[:], want.Signature[:], index[:])
var enc []byte
enc = append(enc, depositRequestType)
enc = append(enc, pubkey[:]...)
enc = append(enc, wxCred[:]...)
enc = append(enc, amount[:]...)
enc = append(enc, sig[:]...)
enc = append(enc, index[:]...)
out, err := depositABI.Pack("DepositEvent", pubkey[:], wxCred[:], amount[:], sig[:], index[:])
if err != nil {
t.Fatalf("error packing deposit: %v", err)
}
got, err := UnpackIntoDeposit(out[4:])
got, err := DepositLogToRequest(out[4:])
if err != nil {
t.Errorf("error unpacking deposit: %v", err)
}
if !reflect.DeepEqual(want, *got) {
t.Errorf("roundtrip failed: want %v, got %v", want, got)
if !bytes.Equal(enc, got) {
t.Errorf("roundtrip failed: want %x, got %x", enc, got)
}
})
}

Loading…
Cancel
Save