api: ethrpc: fix unit test
and skip a non-testing test; printing doesn't constitute testing.
This commit is contained in:
parent
448eca56c8
commit
6d7a33ff70
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
gocrypto "github.com/filecoin-project/go-crypto"
|
gocrypto "github.com/filecoin-project/go-crypto"
|
||||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
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"
|
"github.com/filecoin-project/go-state-types/builtin/v10/evm"
|
||||||
init10 "github.com/filecoin-project/go-state-types/builtin/v10/init"
|
init10 "github.com/filecoin-project/go-state-types/builtin/v10/init"
|
||||||
crypto1 "github.com/filecoin-project/go-state-types/crypto"
|
crypto1 "github.com/filecoin-project/go-state-types/crypto"
|
||||||
@ -133,11 +134,21 @@ func TestDelegatedSigner(t *testing.T) {
|
|||||||
pubKeyHex := "0x04cfecc0520d906cbfea387759246e89d85e2998843e56ad1c41de247ce10b3e4c453aa73c8de13c178d94461b6fa3f8b6f74406ce43d2fbab6992d0b283394242"
|
pubKeyHex := "0x04cfecc0520d906cbfea387759246e89d85e2998843e56ad1c41de247ce10b3e4c453aa73c8de13c178d94461b6fa3f8b6f74406ce43d2fbab6992d0b283394242"
|
||||||
|
|
||||||
msg := mustDecodeHex(msgHex)
|
msg := mustDecodeHex(msgHex)
|
||||||
pubKey := mustDecodeHex(pubKeyHex)
|
pubk := mustDecodeHex(pubKeyHex)
|
||||||
r := mustDecodeHex(rHex)
|
r := mustDecodeHex(rHex)
|
||||||
s := mustDecodeHex(sHex)
|
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(r, s...)
|
||||||
sig = append(sig, v)
|
sig = append(sig, v)
|
||||||
@ -149,7 +160,7 @@ func TestDelegatedSigner(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = sigs.Verify(signature, from, msg)
|
err = sigs.Verify(signature, from, msg)
|
||||||
require.Nil(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareTxTestcases() ([]TxTestcase, error) {
|
func prepareTxTestcases() ([]TxTestcase, error) {
|
||||||
|
@ -175,6 +175,7 @@ func TestDecodeError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDecode1(t *testing.T) {
|
func TestDecode1(t *testing.T) {
|
||||||
|
t.Skip("doesn't really test anything, it just prints stuff...")
|
||||||
b := mustDecodeHex("0x02f8758401df5e7680832c8411832c8411830767f89452963ef50e27e06d72d59fcb4f3c2a687be3cfef880de0b6b3a764000080c080a094b11866f453ad85a980e0e8a2fc98cbaeb4409618c7734a7e12ae2f66fd405da042dbfb1b37af102023830ceeee0e703ffba0b8b3afeb8fe59f405eca9ed61072")
|
b := mustDecodeHex("0x02f8758401df5e7680832c8411832c8411830767f89452963ef50e27e06d72d59fcb4f3c2a687be3cfef880de0b6b3a764000080c080a094b11866f453ad85a980e0e8a2fc98cbaeb4409618c7734a7e12ae2f66fd405da042dbfb1b37af102023830ceeee0e703ffba0b8b3afeb8fe59f405eca9ed61072")
|
||||||
decoded, err := ParseEthTxArgs(b)
|
decoded, err := ParseEthTxArgs(b)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -185,5 +186,5 @@ func TestDecode1(t *testing.T) {
|
|||||||
|
|
||||||
fmt.Println(decoded.Sender())
|
fmt.Println(decoded.Sender())
|
||||||
|
|
||||||
fmt.Printf("%+v", decoded)
|
fmt.Printf("%+v\n", decoded)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user