From 0c1f4a02d9a60c8413b48463a8f241eb038448be Mon Sep 17 00:00:00 2001 From: Piotr Macek <4007944+piotrm50@users.noreply.github.com> Date: Wed, 8 Nov 2023 14:07:16 +0100 Subject: [PATCH] Change the default wallet initialization. --- pkg/testsuite/testsuite.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/testsuite/testsuite.go b/pkg/testsuite/testsuite.go index 3492988de..eb6f43cb0 100644 --- a/pkg/testsuite/testsuite.go +++ b/pkg/testsuite/testsuite.go @@ -410,11 +410,7 @@ func (t *TestSuite) addWallet(name string, node *mock.Node, accountID iotago.Acc } func (t *TestSuite) DefaultWallet() *mock.Wallet { - if t.wallets.Has("default") { - return lo.Return1(t.wallets.Get("default")) - } - - _, defaultWallet, exists := t.wallets.Head() + defaultWallet, exists := t.wallets.Get("default") if !exists { return nil } @@ -426,6 +422,16 @@ func (t *TestSuite) Run(failOnBlockFiltered bool, nodesOptions ...map[string][]o t.mutex.Lock() defer t.mutex.Unlock() + // Add default wallet by default when creating the first node. + if !t.wallets.Has("default") { + _, node, exists := t.nodes.Head() + if !exists { + panic("at least one node is needed to create a default wallet") + } + + t.AddGenesisWallet("default", node) + } + // Create accounts for any block issuer nodes added before starting the network. if t.optsAccounts != nil { t.optsSnapshotOptions = append(t.optsSnapshotOptions, snapshotcreator.WithAccounts(lo.Map(t.optsAccounts, func(accountDetails snapshotcreator.AccountDetails) snapshotcreator.AccountDetails {