mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
update core/types/ transaction_test.go (#953)
update core/types/transaction_test.go Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
This commit is contained in:
parent
17acae881a
commit
536603a85d
1 changed files with 35 additions and 1 deletions
|
|
@ -91,11 +91,33 @@ func TestTransactionSigHash(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTransactionEncode(t *testing.T) {
|
||||
should := common.FromHex("f86103018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a8255441ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3")
|
||||
|
||||
// rlp.EncodeToBytes
|
||||
txb, err := rlp.EncodeToBytes(rightvrsTx)
|
||||
if err != nil {
|
||||
t.Fatalf("encode error: %v", err)
|
||||
}
|
||||
should := common.FromHex("f86103018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a8255441ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3")
|
||||
if !bytes.Equal(txb, should) {
|
||||
t.Errorf("encoded RLP mismatch, got %x", txb)
|
||||
}
|
||||
|
||||
// tx.EncodeRLP
|
||||
raw := new(bytes.Buffer)
|
||||
err = rightvrsTx.EncodeRLP(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("encode error: %v", err)
|
||||
}
|
||||
txb = raw.Bytes()
|
||||
if !bytes.Equal(txb, should) {
|
||||
t.Errorf("encoded RLP mismatch, got %x", txb)
|
||||
}
|
||||
|
||||
// tx.MarshalBinary
|
||||
txb, err = rightvrsTx.MarshalBinary()
|
||||
if err != nil {
|
||||
t.Fatalf("encode error: %v", err)
|
||||
}
|
||||
if !bytes.Equal(txb, should) {
|
||||
t.Errorf("encoded RLP mismatch, got %x", txb)
|
||||
}
|
||||
|
|
@ -190,6 +212,7 @@ func TestEIP2930Signer(t *testing.T) {
|
|||
func TestEIP2718TransactionEncode(t *testing.T) {
|
||||
// RLP representation
|
||||
{
|
||||
// rlp.EncodeToBytes
|
||||
have, err := rlp.EncodeToBytes(signedEip2718Tx)
|
||||
if err != nil {
|
||||
t.Fatalf("encode error: %v", err)
|
||||
|
|
@ -198,6 +221,17 @@ func TestEIP2718TransactionEncode(t *testing.T) {
|
|||
if !bytes.Equal(have, want) {
|
||||
t.Errorf("encoded RLP mismatch, got %x", have)
|
||||
}
|
||||
|
||||
// tx.EncodeRLP
|
||||
raw := new(bytes.Buffer)
|
||||
err = signedEip2718Tx.EncodeRLP(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("encode error: %v", err)
|
||||
}
|
||||
have = raw.Bytes()
|
||||
if !bytes.Equal(have, want) {
|
||||
t.Errorf("encoded RLP mismatch, got %x", have)
|
||||
}
|
||||
}
|
||||
// Binary representation
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue