Skip to content

Commit

Permalink
Fix WalletSign in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Oct 8, 2020
1 parent 6e8efb9 commit 7d2f06c
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 27 deletions.
20 changes: 11 additions & 9 deletions chain/messagepool/selection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"sort"
"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-state-types/crypto"
"github.com/filecoin-project/lotus/build"
Expand All @@ -21,12 +25,10 @@ import (
"github.com/filecoin-project/lotus/chain/types/mock"
"github.com/filecoin-project/lotus/chain/wallet"
"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/secp"
logging "github.com/ipfs/go-log"
)

func init() {
Expand All @@ -45,7 +47,7 @@ func makeTestMessage(w *wallet.LocalWallet, from, to address.Address, nonce uint
GasFeeCap: types.NewInt(100 + 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 {
panic(err)
}
Expand Down Expand Up @@ -744,7 +746,7 @@ func TestPriorityMessageSelection3(t *testing.T) {
t.Fatal(err)
}

a1, err := w1.GenerateKey(crypto.SigTypeSecp256k1)
a1, err := w1.WalletNew(context.Background(), crypto.SigTypeSecp256k1)
if err != nil {
t.Fatal(err)
}
Expand All @@ -754,7 +756,7 @@ func TestPriorityMessageSelection3(t *testing.T) {
t.Fatal(err)
}

a2, err := w2.GenerateKey(crypto.SigTypeSecp256k1)
a2, err := w2.WalletNew(context.Background(), crypto.SigTypeSecp256k1)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -1330,7 +1332,7 @@ readLoop:
}

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 {
baseNonce := baseNonces[m.Message.From]
Expand All @@ -1342,7 +1344,7 @@ readLoop:
t.Fatal(err)
}

a, err := w.GenerateKey(crypto.SigTypeSecp256k1)
a, err := w.WalletNew(context.Background(), crypto.SigTypeSecp256k1)
if err != nil {
t.Fatal(err)
}
Expand All @@ -1360,7 +1362,7 @@ readLoop:
m.Message.From = localActor
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 {
t.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions chain/messagesigner/messagesigner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ func TestMessageSignerSignMessage(t *testing.T) {
ctx := context.Background()

w, _ := wallet.NewWallet(wallet.NewMemKeyStore())
from1, err := w.GenerateKey(crypto.SigTypeSecp256k1)
from1, err := w.WalletNew(ctx, crypto.SigTypeSecp256k1)
require.NoError(t, err)
from2, err := w.GenerateKey(crypto.SigTypeSecp256k1)
from2, err := w.WalletNew(ctx, crypto.SigTypeSecp256k1)
require.NoError(t, err)
to1, err := w.GenerateKey(crypto.SigTypeSecp256k1)
to1, err := w.WalletNew(ctx, crypto.SigTypeSecp256k1)
require.NoError(t, err)
to2, err := w.GenerateKey(crypto.SigTypeSecp256k1)
to2, err := w.WalletNew(ctx, crypto.SigTypeSecp256k1)
require.NoError(t, err)

type msgSpec struct {
Expand Down
19 changes: 10 additions & 9 deletions chain/stmgr/forks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ import (
"io"
"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-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/specs-actors/actors/builtin"
init0 "github.com/filecoin-project/specs-actors/actors/builtin/init"
"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/aerrors"
lotusinit "github.com/filecoin-project/lotus/chain/actors/builtin/init"
Expand All @@ -25,11 +31,6 @@ import (
"github.com/filecoin-project/lotus/chain/vm"
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
_ "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() {
Expand Down Expand Up @@ -186,7 +187,7 @@ func TestForkHeightTriggers(t *testing.T) {
Params: enc,
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 {
t.Fatal(err)
}
Expand Down Expand Up @@ -214,7 +215,7 @@ func TestForkHeightTriggers(t *testing.T) {
}
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 {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions chain/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ func TestDuplicateNonce(t *testing.T) {
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)

return &types.SignedMessage{
Expand Down Expand Up @@ -685,7 +685,7 @@ func TestBadNonce(t *testing.T) {
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)

return &types.SignedMessage{
Expand Down
3 changes: 2 additions & 1 deletion chain/types/mock/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/filecoin-project/go-state-types/crypto"
"github.com/ipfs/go-cid"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
Expand All @@ -33,7 +34,7 @@ func MkMessage(from, to address.Address, nonce uint64, w *wallet.LocalWallet) *t
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 {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/lotus-shed/keyinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var keyinfoVerifyCmd = &cli.Command{
return err
}

if _, err := w.Import(&keyInfo); err != nil {
if _, err := w.WalletImport(cctx.Context, &keyInfo); err != nil {
return err
}

Expand Down
4 changes: 3 additions & 1 deletion node/impl/full/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func (a *WalletAPI) WalletSign(ctx context.Context, k address.Address, msg []byt
if err != nil {
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) {
Expand Down

0 comments on commit 7d2f06c

Please sign in to comment.