From 4a63eb6e23fd0629b99738dba17cb714231381e0 Mon Sep 17 00:00:00 2001 From: rawdaGastan Date: Thu, 31 Oct 2024 16:05:53 +0300 Subject: [PATCH] use our mnemonic instead if alice --- farmerbot/internal/farmerbot_test.go | 12 ++++++++++-- grid-client/deployer/deployer_test.go | 9 ++++++++- tfrobot/internal/parser/parser_test.go | 8 +++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/farmerbot/internal/farmerbot_test.go b/farmerbot/internal/farmerbot_test.go index b0542646e..4a6d57a40 100644 --- a/farmerbot/internal/farmerbot_test.go +++ b/farmerbot/internal/farmerbot_test.go @@ -2,11 +2,13 @@ package internal import ( "context" + "os" "testing" "github.com/centrifuge/go-substrate-rpc-client/v4/types" "github.com/golang/mock/gomock" "github.com/pkg/errors" + "github.com/rs/zerolog/log" "github.com/stretchr/testify/assert" substrate "github.com/threefoldtech/tfchain/clients/tfchain-client-go" "github.com/threefoldtech/tfgrid-sdk-go/farmerbot/mocks" @@ -41,7 +43,13 @@ func TestFarmerbot(t *testing.T) { }}, } - farmerbot, err := NewFarmerBot(ctx, inputs, "dev", aliceSeed, peer.KeyTypeSr25519) + mnemonic := os.Getenv("MNEMONICS") + log.Debug().Str("MNEMONICS", mnemonic).Send() + if len(mnemonic) == 0 { + mnemonic = aliceSeed + } + + farmerbot, err := NewFarmerBot(ctx, inputs, "dev", mnemonic, peer.KeyTypeSr25519) assert.Error(t, err) farmerbot.rmbNodeClient = rmb farmerbot.gridProxyClient = proxy @@ -63,7 +71,7 @@ func TestFarmerbot(t *testing.T) { }) t.Run("test serve", func(t *testing.T) { - farmerbot.substrateManager = substrate.NewManager(SubstrateURLs[DevNetwork]...) + farmerbot.substrateManager = substrate.NewManager(SubstrateURLs[QaNetwork]...) identity, err := substrate.NewIdentityFromSr25519Phrase(aliceSeed) assert.NoError(t, err) farmerbot.identity = identity diff --git a/grid-client/deployer/deployer_test.go b/grid-client/deployer/deployer_test.go index 8af820adc..5fc9da41e 100644 --- a/grid-client/deployer/deployer_test.go +++ b/grid-client/deployer/deployer_test.go @@ -29,14 +29,21 @@ var ( ) func setup() (TFPluginClient, error) { + mnemonic := os.Getenv("MNEMONICS") + log.Debug().Str("MNEMONICS", mnemonic).Send() + if len(mnemonic) == 0 { + mnemonic = "//Alice" + } + network := os.Getenv("NETWORK") if len(network) == 0 { network = "dev" } + log.Debug().Msgf("network: %s", network) // Alice identity - aliceIdentity, err := substrate.NewIdentityFromSr25519Phrase("//Alice") + aliceIdentity, err := substrate.NewIdentityFromSr25519Phrase(mnemonic) if err != nil { return TFPluginClient{}, err } diff --git a/tfrobot/internal/parser/parser_test.go b/tfrobot/internal/parser/parser_test.go index 42255e880..1fa75d2f9 100644 --- a/tfrobot/internal/parser/parser_test.go +++ b/tfrobot/internal/parser/parser_test.go @@ -17,11 +17,17 @@ import ( ) func TestParseConfig(t *testing.T) { + mnemonic := os.Getenv("MNEMONICS") + log.Debug().Str("MNEMONICS", mnemonic).Send() + if len(mnemonic) == 0 { + mnemonic = "//Alice" + } + log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) validFlist := "https://hub.grid.tf/tf-official-apps/base:latest.flist" // Alice identity - aliceIdentity, err := substrate.NewIdentityFromSr25519Phrase("//Alice") + aliceIdentity, err := substrate.NewIdentityFromSr25519Phrase(mnemonic) assert.NoError(t, err) keyPair, err := aliceIdentity.KeyPair()