Fix WalletSign in tests
This commit is contained in:
parent
6e8efb9d2c
commit
7d2f06cfbd
@ -13,6 +13,10 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
"github.com/ipfs/go-datastore"
|
||||||
|
logging "github.com/ipfs/go-log"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-state-types/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@ -21,12 +25,10 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types/mock"
|
"github.com/filecoin-project/lotus/chain/types/mock"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
"github.com/ipfs/go-datastore"
|
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||||
logging "github.com/ipfs/go-log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -45,7 +47,7 @@ func makeTestMessage(w *wallet.LocalWallet, from, to address.Address, nonce uint
|
|||||||
GasFeeCap: types.NewInt(100 + gasPrice),
|
GasFeeCap: types.NewInt(100 + gasPrice),
|
||||||
GasPremium: types.NewInt(gasPrice),
|
GasPremium: types.NewInt(gasPrice),
|
||||||
}
|
}
|
||||||
sig, err := w.WalletSign(context.TODO(), from, msg.Cid().Bytes())
|
sig, err := w.WalletSign(context.TODO(), from, msg.Cid().Bytes(), api.MsgMeta{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -744,7 +746,7 @@ func TestPriorityMessageSelection3(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a1, err := w1.GenerateKey(crypto.SigTypeSecp256k1)
|
a1, err := w1.WalletNew(context.Background(), crypto.SigTypeSecp256k1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -754,7 +756,7 @@ func TestPriorityMessageSelection3(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a2, err := w2.GenerateKey(crypto.SigTypeSecp256k1)
|
a2, err := w2.WalletNew(context.Background(), crypto.SigTypeSecp256k1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -1330,7 +1332,7 @@ readLoop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
actorMap := make(map[address.Address]address.Address)
|
actorMap := make(map[address.Address]address.Address)
|
||||||
actorWallets := make(map[address.Address]*wallet.Wallet)
|
actorWallets := make(map[address.Address]api.WalletAPI)
|
||||||
|
|
||||||
for _, m := range msgs {
|
for _, m := range msgs {
|
||||||
baseNonce := baseNonces[m.Message.From]
|
baseNonce := baseNonces[m.Message.From]
|
||||||
@ -1342,7 +1344,7 @@ readLoop:
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a, err := w.GenerateKey(crypto.SigTypeSecp256k1)
|
a, err := w.WalletNew(context.Background(), crypto.SigTypeSecp256k1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -1360,7 +1362,7 @@ readLoop:
|
|||||||
m.Message.From = localActor
|
m.Message.From = localActor
|
||||||
m.Message.Nonce -= baseNonce
|
m.Message.Nonce -= baseNonce
|
||||||
|
|
||||||
sig, err := w.Sign(context.TODO(), localActor, m.Message.Cid().Bytes())
|
sig, err := w.WalletSign(context.TODO(), localActor, m.Message.Cid().Bytes(), api.MsgMeta{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -47,13 +47,13 @@ func TestMessageSignerSignMessage(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
w, _ := wallet.NewWallet(wallet.NewMemKeyStore())
|
w, _ := wallet.NewWallet(wallet.NewMemKeyStore())
|
||||||
from1, err := w.GenerateKey(crypto.SigTypeSecp256k1)
|
from1, err := w.WalletNew(ctx, crypto.SigTypeSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
from2, err := w.GenerateKey(crypto.SigTypeSecp256k1)
|
from2, err := w.WalletNew(ctx, crypto.SigTypeSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
to1, err := w.GenerateKey(crypto.SigTypeSecp256k1)
|
to1, err := w.WalletNew(ctx, crypto.SigTypeSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
to2, err := w.GenerateKey(crypto.SigTypeSecp256k1)
|
to2, err := w.WalletNew(ctx, crypto.SigTypeSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
type msgSpec struct {
|
type msgSpec struct {
|
||||||
|
@ -6,15 +6,21 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
ipldcbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
logging "github.com/ipfs/go-log"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/cbor"
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
init0 "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
init0 "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"golang.org/x/xerrors"
|
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||||
lotusinit "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
lotusinit "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||||
@ -25,11 +31,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
ipldcbor "github.com/ipfs/go-ipld-cbor"
|
|
||||||
logging "github.com/ipfs/go-log"
|
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -186,7 +187,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
|||||||
Params: enc,
|
Params: enc,
|
||||||
GasLimit: types.TestGasLimit,
|
GasLimit: types.TestGasLimit,
|
||||||
}
|
}
|
||||||
sig, err := cg.Wallet().WalletSign(ctx, cg.Banker(), m.Cid().Bytes())
|
sig, err := cg.Wallet().WalletSign(ctx, cg.Banker(), m.Cid().Bytes(), api.MsgMeta{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -214,7 +215,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
nonce++
|
nonce++
|
||||||
|
|
||||||
sig, err := cg.Wallet().WalletSign(ctx, cg.Banker(), m.Cid().Bytes())
|
sig, err := cg.Wallet().WalletSign(ctx, cg.Banker(), m.Cid().Bytes(), api.MsgMeta{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -593,7 +593,7 @@ func TestDuplicateNonce(t *testing.T) {
|
|||||||
GasPremium: types.NewInt(0),
|
GasPremium: types.NewInt(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
sig, err := tu.g.Wallet().WalletSign(context.TODO(), tu.g.Banker(), msg.Cid().Bytes())
|
sig, err := tu.g.Wallet().WalletSign(context.TODO(), tu.g.Banker(), msg.Cid().Bytes(), api.MsgMeta{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return &types.SignedMessage{
|
return &types.SignedMessage{
|
||||||
@ -685,7 +685,7 @@ func TestBadNonce(t *testing.T) {
|
|||||||
GasPremium: types.NewInt(0),
|
GasPremium: types.NewInt(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
sig, err := tu.g.Wallet().Sign(context.TODO(), tu.g.Banker(), msg.Cid().Bytes())
|
sig, err := tu.g.Wallet().WalletSign(context.TODO(), tu.g.Banker(), msg.Cid().Bytes(), api.MsgMeta{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return &types.SignedMessage{
|
return &types.SignedMessage{
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet"
|
||||||
@ -33,7 +34,7 @@ func MkMessage(from, to address.Address, nonce uint64, w *wallet.LocalWallet) *t
|
|||||||
GasPremium: types.NewInt(1),
|
GasPremium: types.NewInt(1),
|
||||||
}
|
}
|
||||||
|
|
||||||
sig, err := w.WalletSign(context.TODO(), from, msg.Cid().Bytes())
|
sig, err := w.WalletSign(context.TODO(), from, msg.Cid().Bytes(), api.MsgMeta{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ var keyinfoVerifyCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := w.Import(&keyInfo); err != nil {
|
if _, err := w.WalletImport(cctx.Context, &keyInfo); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,9 @@ func (a *WalletAPI) WalletSign(ctx context.Context, k address.Address, msg []byt
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to resolve ID address: %w", keyAddr)
|
return nil, xerrors.Errorf("failed to resolve ID address: %w", keyAddr)
|
||||||
}
|
}
|
||||||
return a.WalletSign(ctx, keyAddr, msg)
|
return a.WalletAPI.WalletSign(ctx, keyAddr, msg, api.MsgMeta{
|
||||||
|
Type: api.MTUnknown,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *WalletAPI) WalletSignMessage(ctx context.Context, k address.Address, msg *types.Message) (*types.SignedMessage, error) {
|
func (a *WalletAPI) WalletSignMessage(ctx context.Context, k address.Address, msg *types.Message) (*types.SignedMessage, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user