From 6d7a33ff70b455f444870415f98b20254acd8ebb Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 9 Nov 2022 21:31:59 +0200 Subject: [PATCH] api: ethrpc: fix unit test and skip a non-testing test; printing doesn't constitute testing. --- api/eth_transactions_test.go | 19 +++++++++++++++---- api/rlp_test.go | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/api/eth_transactions_test.go b/api/eth_transactions_test.go index 23ff1f82b..b9046a7b6 100644 --- a/api/eth_transactions_test.go +++ b/api/eth_transactions_test.go @@ -13,6 +13,7 @@ import ( "github.com/filecoin-project/go-address" gocrypto "github.com/filecoin-project/go-crypto" actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/builtin/v10/evm" init10 "github.com/filecoin-project/go-state-types/builtin/v10/init" crypto1 "github.com/filecoin-project/go-state-types/crypto" @@ -133,11 +134,21 @@ func TestDelegatedSigner(t *testing.T) { pubKeyHex := "0x04cfecc0520d906cbfea387759246e89d85e2998843e56ad1c41de247ce10b3e4c453aa73c8de13c178d94461b6fa3f8b6f74406ce43d2fbab6992d0b283394242" msg := mustDecodeHex(msgHex) - pubKey := mustDecodeHex(pubKeyHex) + pubk := mustDecodeHex(pubKeyHex) r := mustDecodeHex(rHex) s := mustDecodeHex(sHex) - from, err := address.NewSecp256k1Address(pubKey) - require.Nil(t, err) + + if pubk[0] == 0x04 { + pubk = pubk[1:] + } + + hasher := sha3.NewLegacyKeccak256() + hasher.Reset() + hasher.Write(pubk) + addrHash := hasher.Sum(nil) + + from, err := address.NewDelegatedAddress(builtin.EthereumAddressManagerActorID, addrHash[12:]) + require.NoError(t, err) sig := append(r, s...) sig = append(sig, v) @@ -149,7 +160,7 @@ func TestDelegatedSigner(t *testing.T) { } err = sigs.Verify(signature, from, msg) - require.Nil(t, err) + require.NoError(t, err) } func prepareTxTestcases() ([]TxTestcase, error) { diff --git a/api/rlp_test.go b/api/rlp_test.go index a6823e5ad..54d1473fd 100644 --- a/api/rlp_test.go +++ b/api/rlp_test.go @@ -175,6 +175,7 @@ func TestDecodeError(t *testing.T) { } func TestDecode1(t *testing.T) { + t.Skip("doesn't really test anything, it just prints stuff...") b := mustDecodeHex("0x02f8758401df5e7680832c8411832c8411830767f89452963ef50e27e06d72d59fcb4f3c2a687be3cfef880de0b6b3a764000080c080a094b11866f453ad85a980e0e8a2fc98cbaeb4409618c7734a7e12ae2f66fd405da042dbfb1b37af102023830ceeee0e703ffba0b8b3afeb8fe59f405eca9ed61072") decoded, err := ParseEthTxArgs(b) require.NoError(t, err) @@ -185,5 +186,5 @@ func TestDecode1(t *testing.T) { fmt.Println(decoded.Sender()) - fmt.Printf("%+v", decoded) + fmt.Printf("%+v\n", decoded) }