Skip to content

Commit

Permalink
sign load packages on integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Villaquiranm committed Jan 7, 2025
1 parent 9f59ccb commit 1c49150
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gno.land/pkg/gnoclient/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ func loadpkgs(t *testing.T, rootdir string, paths ...string) []gnoland.TxWithMet

meta, err := loader.LoadPackages(creator, defaultFee, nil)
require.NoError(t, err)

err = integration.SignTxs(meta, "tendermint_test")
require.NoError(t, err)
return meta
}
32 changes: 32 additions & 0 deletions gno.land/pkg/integration/defaultsigner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package integration

import (
"github.com/gnolang/gno/gno.land/pkg/gnoland"
"github.com/gnolang/gno/tm2/pkg/crypto/keys"
"github.com/gnolang/gno/tm2/pkg/std"
)

func SignTxs(txs []gnoland.TxWithMetadata, chainID string) error {
kb := keys.NewInMemory()
_, err := kb.CreateAccount(DefaultAccount_Name, DefaultAccount_Seed, "", "", 0, 0)
if err != nil {
return err
}
for index, tx := range txs {
bytes, err := tx.Tx.GetSignBytes(chainID, 0, 0)
if err != nil {
return err
}
signature, publicKey, err := kb.Sign(DefaultAccount_Name, "", bytes)
if err != nil {
return err
}
txs[index].Tx.Signatures = []std.Signature{
{
PubKey: publicKey,
Signature: signature,
},
}
}
return nil
}

0 comments on commit 1c49150

Please sign in to comment.