mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-06-13 09:36:41 +00:00
fix asset e2e test suite for extended keypair
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
a8c4633e95
commit
f7253024d2
@ -1,10 +1,13 @@
|
|||||||
package asset
|
package asset
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"planetmint-go/testutil"
|
"planetmint-go/testutil"
|
||||||
"planetmint-go/testutil/sample"
|
"planetmint-go/testutil/sample"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/btcutil/hdkeychain"
|
||||||
|
|
||||||
assettypes "planetmint-go/x/asset/types"
|
assettypes "planetmint-go/x/asset/types"
|
||||||
|
|
||||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||||
@ -21,7 +24,11 @@ func (s *E2ETestSuite) TestNotarizeAssetREST() {
|
|||||||
addr, err := k.GetAddress()
|
addr, err := k.GetAddress()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
cidHash, signature := sample.Asset(prvKey)
|
xskKey, _ := hdkeychain.NewKeyFromString(xPrvKey)
|
||||||
|
privKey, _ := xskKey.ECPrivKey()
|
||||||
|
byte_key := privKey.Serialize()
|
||||||
|
sk := hex.EncodeToString(byte_key)
|
||||||
|
cidHash, signature := sample.Asset(sk)
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
@ -44,7 +51,7 @@ func (s *E2ETestSuite) TestNotarizeAssetREST() {
|
|||||||
Creator: addr.String(),
|
Creator: addr.String(),
|
||||||
Hash: cidHash,
|
Hash: cidHash,
|
||||||
Signature: "invalid signature",
|
Signature: "invalid signature",
|
||||||
PubKey: pubKey,
|
PubKey: xPubKey,
|
||||||
},
|
},
|
||||||
"invalid signature",
|
"invalid signature",
|
||||||
},
|
},
|
||||||
@ -54,7 +61,7 @@ func (s *E2ETestSuite) TestNotarizeAssetREST() {
|
|||||||
Creator: addr.String(),
|
Creator: addr.String(),
|
||||||
Hash: cidHash,
|
Hash: cidHash,
|
||||||
Signature: signature,
|
Signature: signature,
|
||||||
PubKey: pubKey,
|
PubKey: xPubKey,
|
||||||
},
|
},
|
||||||
"planetmintgo.asset.MsgNotarizeAsset",
|
"planetmintgo.asset.MsgNotarizeAsset",
|
||||||
},
|
},
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package asset
|
package asset
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"planetmint-go/config"
|
||||||
"planetmint-go/testutil/network"
|
"planetmint-go/testutil/network"
|
||||||
"planetmint-go/testutil/sample"
|
"planetmint-go/testutil/sample"
|
||||||
|
|
||||||
@ -10,6 +12,7 @@ import (
|
|||||||
assetcli "planetmint-go/x/asset/client/cli"
|
assetcli "planetmint-go/x/asset/client/cli"
|
||||||
machinecli "planetmint-go/x/machine/client/cli"
|
machinecli "planetmint-go/x/machine/client/cli"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/btcutil/hdkeychain"
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||||
@ -19,8 +22,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pubKey string
|
pubKey string
|
||||||
prvKey string
|
prvKey string
|
||||||
|
xPubKey string
|
||||||
|
xPrvKey string
|
||||||
)
|
)
|
||||||
|
|
||||||
// E2ETestSuite struct definition of asset suite
|
// E2ETestSuite struct definition of asset suite
|
||||||
@ -72,6 +77,7 @@ func (s *E2ETestSuite) SetupSuite() {
|
|||||||
s.Require().NoError(s.network.WaitForNextBlock())
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
|
||||||
prvKey, pubKey = sample.KeyPair()
|
prvKey, pubKey = sample.KeyPair()
|
||||||
|
xPrvKey, xPubKey = sample.ExtendedKeyPair(config.PlmntNetParams)
|
||||||
|
|
||||||
ta := sample.TrustAnchor(pubKey)
|
ta := sample.TrustAnchor(pubKey)
|
||||||
taJSON, err := json.Marshal(&ta)
|
taJSON, err := json.Marshal(&ta)
|
||||||
@ -121,7 +127,11 @@ func (s *E2ETestSuite) TearDownSuite() {
|
|||||||
func (s *E2ETestSuite) TestNotarizeAsset() {
|
func (s *E2ETestSuite) TestNotarizeAsset() {
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
|
|
||||||
cidHash, signature := sample.Asset(prvKey)
|
xskKey, _ := hdkeychain.NewKeyFromString(xPrvKey)
|
||||||
|
privKey, _ := xskKey.ECPrivKey()
|
||||||
|
byte_key := privKey.Serialize()
|
||||||
|
sk := hex.EncodeToString(byte_key)
|
||||||
|
cidHash, signature := sample.Asset(sk)
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
@ -145,7 +155,7 @@ func (s *E2ETestSuite) TestNotarizeAsset() {
|
|||||||
[]string{
|
[]string{
|
||||||
"cid",
|
"cid",
|
||||||
"signature",
|
"signature",
|
||||||
pubKey,
|
xPubKey,
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, sample.Name),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, sample.Name),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees),
|
||||||
"--yes",
|
"--yes",
|
||||||
@ -157,7 +167,7 @@ func (s *E2ETestSuite) TestNotarizeAsset() {
|
|||||||
[]string{
|
[]string{
|
||||||
cidHash,
|
cidHash,
|
||||||
signature,
|
signature,
|
||||||
pubKey,
|
xPubKey,
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, sample.Name),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, sample.Name),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees),
|
||||||
"--yes",
|
"--yes",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user