mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-10-14 00:59:21 +00:00
fix machine test
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
120d3fdd9d
commit
f74aae8e6e
@ -20,15 +20,30 @@ func (s *E2ETestSuite) TestAttestMachineREST() {
|
|||||||
addr, err := k.GetAddress()
|
addr, err := k.GetAddress()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
prvKey, pubKey := sample.KeyPair(1)
|
||||||
|
|
||||||
|
// Register TA
|
||||||
|
ta := sample.TrustAnchor(pubKey)
|
||||||
|
taMsg := machinetypes.MsgRegisterTrustAnchor{
|
||||||
|
Creator: addr.String(),
|
||||||
|
TrustAnchor: &ta,
|
||||||
|
}
|
||||||
|
txBytes, err := testutil.PrepareTx(val, &taMsg, sample.Name)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
_, err = testutil.BroadcastTx(val, txBytes)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
|
||||||
// Create Attest Machine TX
|
// Create Attest Machine TX
|
||||||
pubKey, prvKey := sample.KeyPair()
|
|
||||||
machine := sample.Machine(sample.Name, pubKey, prvKey)
|
machine := sample.Machine(sample.Name, pubKey, prvKey)
|
||||||
msg := machinetypes.MsgAttestMachine{
|
msg := machinetypes.MsgAttestMachine{
|
||||||
Creator: addr.String(),
|
Creator: addr.String(),
|
||||||
Machine: &machine,
|
Machine: &machine,
|
||||||
}
|
}
|
||||||
|
|
||||||
txBytes, err := testutil.PrepareTx(val, &msg, sample.Name)
|
txBytes, err = testutil.PrepareTx(val, &msg, sample.Name)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
broadcastTxResponse, err := testutil.BroadcastTx(val, txBytes)
|
broadcastTxResponse, err := testutil.BroadcastTx(val, txBytes)
|
||||||
|
@ -2,6 +2,7 @@ package sample
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"planetmint-go/config"
|
"planetmint-go/config"
|
||||||
machinetypes "planetmint-go/x/machine/types"
|
machinetypes "planetmint-go/x/machine/types"
|
||||||
@ -34,8 +35,12 @@ const Fees = "2stake"
|
|||||||
const DefaultDerivationPath = "m/44'/8680'/0'/0/0"
|
const DefaultDerivationPath = "m/44'/8680'/0'/0/0"
|
||||||
|
|
||||||
// KeyPair returns a sample private / public keypair
|
// KeyPair returns a sample private / public keypair
|
||||||
func KeyPair() (string, string) {
|
func KeyPair(optional ...int) (string, string) {
|
||||||
secret := "Don't tell anybody"
|
secret := "Don't tell anybody"
|
||||||
|
// optional value if different keypairs are needed
|
||||||
|
if len(optional) > 0 {
|
||||||
|
secret = fmt.Sprintf("%v%v", secret, optional[0])
|
||||||
|
}
|
||||||
sk := secp256k1.GenPrivKeyFromSecret([]byte(secret))
|
sk := secp256k1.GenPrivKeyFromSecret([]byte(secret))
|
||||||
pk := sk.PubKey()
|
pk := sk.PubKey()
|
||||||
return hex.EncodeToString(sk.Bytes()), hex.EncodeToString(pk.Bytes())
|
return hex.EncodeToString(sk.Bytes()), hex.EncodeToString(pk.Bytes())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user