From c5c5faa4e1482f0b8ec88d05c3d696c93226a44d Mon Sep 17 00:00:00 2001 From: gfanton <8671905+gfanton@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:18:44 +0100 Subject: [PATCH] fix: test pk Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com> --- gno.land/pkg/integration/forknode/main.go | 30 +++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/gno.land/pkg/integration/forknode/main.go b/gno.land/pkg/integration/forknode/main.go index 13ed48016eda..5bcc6866fbd9 100644 --- a/gno.land/pkg/integration/forknode/main.go +++ b/gno.land/pkg/integration/forknode/main.go @@ -17,9 +17,8 @@ import ( "github.com/gnolang/gno/tm2/pkg/db/memdb" ) -// isAllZero checks if all elements in the [64]byte array are zero. -func isAllZero(arr [64]byte) bool { - for _, v := range arr { +func isAllZero(key [64]byte) bool { + for _, v := range key { if v != 0 { return false } @@ -46,33 +45,38 @@ func ForkableNode(cfg *integration.ForkConfig) error { if len(cfg.PrivValidator) > 0 && !isAllZero(cfg.PrivValidator) { nodecfg.PrivValidator = bft.NewMockPVWithParams(cfg.PrivValidator, false, false) - pv := nodecfg.PrivValidator.GetPubKey() - nodecfg.Genesis.Validators = []bft.GenesisValidator{ - { - Address: pv.Address(), - PubKey: pv, - Power: 10, - Name: "self", - }, - } - } + pv := nodecfg.PrivValidator.GetPubKey() nodecfg.DB = data nodecfg.TMConfig.DBPath = cfg.DBDir nodecfg.TMConfig = cfg.TMConfig nodecfg.Genesis = cfg.Genesis.ToGenesisDoc() + nodecfg.Genesis.Validators = []bft.GenesisValidator{ + { + Address: pv.Address(), + PubKey: pv, + Power: 10, + Name: "self", + }, + } + + fmt.Println("NEW NODE") node, err := gnoland.NewInMemoryNode(logger, nodecfg) if err != nil { return fmt.Errorf("failed to create new in-memory node: %w", err) } + fmt.Println(">>>STARTING") + err = node.Start() if err != nil { return fmt.Errorf("failed to start node: %w", err) } + fmt.Println(">>>STARTING DONE") + ourAddress := nodecfg.PrivValidator.GetPubKey().Address() isValidator := slices.ContainsFunc(nodecfg.Genesis.Validators, func(val bft.GenesisValidator) bool { return val.Address == ourAddress