github.com/lino-network/lino@v0.6.11/test/account/recover_test.go (about) 1 package account 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/lino-network/lino/test" 8 "github.com/lino-network/lino/types" 9 accmodel "github.com/lino-network/lino/x/account/model" 10 acctypes "github.com/lino-network/lino/x/account/types" 11 12 sdk "github.com/cosmos/cosmos-sdk/types" 13 "github.com/tendermint/tendermint/crypto/secp256k1" 14 ) 15 16 func TestRecoverAccount(t *testing.T) { 17 transactionPriv := secp256k1.GenPrivKey() 18 signingPriv := secp256k1.GenPrivKey() 19 newTransactionPriv := secp256k1.GenPrivKey() 20 newSigningPriv := secp256k1.GenPrivKey() 21 newAccountName := "newuser" 22 23 baseT := time.Unix(0, 0) 24 baseTime := baseT.Unix() 25 lb := test.NewTestLinoBlockchain(t, test.DefaultNumOfVal, baseT) 26 27 registerMsgV2 := acctypes.NewRegisterV2Msg( 28 types.NewAccOrAddrFromAcc( 29 types.AccountKey(test.GenesisUser)), newAccountName, types.LNO("100"), 30 transactionPriv.PubKey(), signingPriv.PubKey()) 31 test.SignCheckDeliverWithMultiSig( 32 t, lb, registerMsgV2, []uint64{0, 0}, true, 33 []secp256k1.PrivKeySecp256k1{test.GenesisTransactionPriv, transactionPriv}, baseTime) 34 35 recoverMsg := acctypes.NewRecoverMsg(newAccountName, newTransactionPriv.PubKey(), newSigningPriv.PubKey()) 36 test.SignCheckDeliverWithMultiSig( 37 t, lb, recoverMsg, []uint64{1, 0}, true, 38 []secp256k1.PrivKeySecp256k1{transactionPriv, newTransactionPriv}, baseTime) 39 test.CheckAccountInfo(t, newAccountName, lb, accmodel.AccountInfo{ 40 Username: types.AccountKey(newAccountName), 41 TransactionKey: newTransactionPriv.PubKey(), 42 SigningKey: newSigningPriv.PubKey(), 43 CreatedAt: baseTime, 44 Address: sdk.AccAddress(newTransactionPriv.PubKey().Address()), 45 }) 46 }