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 e33600f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 0 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,5 @@ func loadpkgs(t *testing.T, rootdir string, paths ...string) []gnoland.TxWithMet

meta, err := loader.LoadPackages(creator, defaultFee, nil)
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
}

Check warning on line 14 in gno.land/pkg/integration/defaultsigner.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/integration/defaultsigner.go#L13-L14

Added lines #L13 - L14 were not covered by tests
for index, tx := range txs {
bytes, err := tx.Tx.GetSignBytes(chainID, 0, 0)
if err != nil {
return err
}

Check warning on line 19 in gno.land/pkg/integration/defaultsigner.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/integration/defaultsigner.go#L18-L19

Added lines #L18 - L19 were not covered by tests
signature, publicKey, err := kb.Sign(DefaultAccount_Name, "", bytes)
if err != nil {
return err
}

Check warning on line 23 in gno.land/pkg/integration/defaultsigner.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/integration/defaultsigner.go#L22-L23

Added lines #L22 - L23 were not covered by tests
txs[index].Tx.Signatures = []std.Signature{
{
PubKey: publicKey,
Signature: signature,
},
}
}
return nil
}
5 changes: 5 additions & 0 deletions gno.land/pkg/integration/pkgloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ func (pl *PkgsLoader) LoadPackages(creator bft.Address, fee std.Fee, deposit std
}
}

err = SignTxs(txs, "tendermint_test")
if err != nil {
return nil, fmt.Errorf("unable to sign txs: %w", err)
}

Check warning on line 83 in gno.land/pkg/integration/pkgloader.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/integration/pkgloader.go#L82-L83

Added lines #L82 - L83 were not covered by tests

return txs, nil
}

Expand Down

0 comments on commit e33600f

Please sign in to comment.