From 5e2ca66a307d6a2557790e1efd5c4d8ff25fd618 Mon Sep 17 00:00:00 2001 From: Miguel Victoria Date: Sun, 24 Nov 2024 16:08:48 +0100 Subject: [PATCH] Fix tests --- contribs/gnogenesis/internal/txs/txs_add_packages.go | 2 +- gno.land/cmd/gnoland/start.go | 2 +- gno.land/cmd/gnoland/start_test.go | 5 +++-- gno.land/pkg/gnoland/genesis.go | 4 ++-- gno.land/pkg/integration/testing_node.go | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/contribs/gnogenesis/internal/txs/txs_add_packages.go b/contribs/gnogenesis/internal/txs/txs_add_packages.go index 5d234336b45..26867505db2 100644 --- a/contribs/gnogenesis/internal/txs/txs_add_packages.go +++ b/contribs/gnogenesis/internal/txs/txs_add_packages.go @@ -70,7 +70,7 @@ func execTxsAddPackages( parsedTxs := make([]gnoland.TxWithMetadata, 0) for _, path := range args { // Generate transactions from the packages (recursively) - txs, err := gnoland.LoadPackagesFromDir(path, cfg.deployerMnemonic, genesisDeployFee) + txs, err := gnoland.LoadPackagesFromDir(path, cfg.deployerMnemonic, genesis.ChainID, genesisDeployFee) if err != nil { return fmt.Errorf("unable to load txs from directory, %w", err) } diff --git a/gno.land/cmd/gnoland/start.go b/gno.land/cmd/gnoland/start.go index a347b1c1691..947b3381e66 100644 --- a/gno.land/cmd/gnoland/start.go +++ b/gno.land/cmd/gnoland/start.go @@ -396,7 +396,7 @@ func generateGenesisFile(genesisFile string, pk crypto.PubKey, c *startCfg) erro // Load examples folder examplesDir := filepath.Join(c.gnoRootDir, "examples") - pkgsTxs, err := gnoland.LoadPackagesFromDir(examplesDir, deployerMnemonic, genesisDeployFee) + pkgsTxs, err := gnoland.LoadPackagesFromDir(examplesDir, deployerMnemonic, c.chainID, genesisDeployFee) if err != nil { return fmt.Errorf("unable to load examples folder: %w", err) } diff --git a/gno.land/cmd/gnoland/start_test.go b/gno.land/cmd/gnoland/start_test.go index 2f620fcd360..f5c9b90e36e 100644 --- a/gno.land/cmd/gnoland/start_test.go +++ b/gno.land/cmd/gnoland/start_test.go @@ -116,7 +116,8 @@ func TestStart_Lazy(t *testing.T) { io.SetErr(commands.WriteNopCloser(mockErr)) // Create and run the command - ctx, cancelFn := context.WithTimeout(context.Background(), 10*time.Second) + // Now lazy init takes longer as we're signing each transaction + ctx, cancelFn := context.WithTimeout(context.Background(), 100*time.Second) defer cancelFn() // Set up the command ctx @@ -128,7 +129,7 @@ func TestStart_Lazy(t *testing.T) { }) // Set up the retry ctx - retryCtx, retryCtxCancelFn := context.WithTimeout(ctx, 5*time.Second) + retryCtx, retryCtxCancelFn := context.WithTimeout(ctx, 100*time.Hour) defer retryCtxCancelFn() // This is a very janky way to verify the node has started. diff --git a/gno.land/pkg/gnoland/genesis.go b/gno.land/pkg/gnoland/genesis.go index 28c43e319bd..f076eae0728 100644 --- a/gno.land/pkg/gnoland/genesis.go +++ b/gno.land/pkg/gnoland/genesis.go @@ -134,7 +134,7 @@ func LoadGenesisTxsFile(path string, chainID string, genesisRemote string) ([]Tx // LoadPackagesFromDir loads gno packages from a directory. // It creates and returns a list of transactions based on these packages. -func LoadPackagesFromDir(dir string, creatorMnemonic string, fee std.Fee) ([]TxWithMetadata, error) { +func LoadPackagesFromDir(dir string, creatorMnemonic string, chainID string, fee std.Fee) ([]TxWithMetadata, error) { // list all packages from target path pkgs, err := gnomod.ListPkgs(dir) if err != nil { @@ -174,7 +174,7 @@ func LoadPackagesFromDir(dir string, creatorMnemonic string, fee std.Fee) ([]TxW return nil, fmt.Errorf("unable to load package %q: %w", pkg.Dir, err) } - txData, err := tx.GetSignBytes("dev", 0, accountSequence) + txData, err := tx.GetSignBytes(chainID, 0, accountSequence) if err != nil { return nil, fmt.Errorf("unable to generate mnemonic, %w", err) } diff --git a/gno.land/pkg/integration/testing_node.go b/gno.land/pkg/integration/testing_node.go index 3dcff28bbdf..af6df426aa2 100644 --- a/gno.land/pkg/integration/testing_node.go +++ b/gno.land/pkg/integration/testing_node.go @@ -134,7 +134,7 @@ func LoadDefaultPackages(t TestingTS, creatorMnemonic string, gnoroot string) [] examplesDir := filepath.Join(gnoroot, "examples") defaultFee := std.NewFee(50000, std.MustParseCoin(ugnot.ValueString(1000000))) - txs, err := gnoland.LoadPackagesFromDir(examplesDir, creatorMnemonic, defaultFee) + txs, err := gnoland.LoadPackagesFromDir(examplesDir, creatorMnemonic, "dev", defaultFee) require.NoError(t, err) return txs