Skip to content

Commit

Permalink
fix(interchaintest): incorrect package name in contract_test.go (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk authored Jun 7, 2024
1 parent ec84412 commit 5abac15
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/interchaintest/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func AddContract(schemaPath, suiteDir, contractName string) error {
}

relPackageDir := filepath.Join(relContractsDir, packageName)
contractTestGenerators, err := getContractTestGenerators(relPackageDir, goMod.Module.Mod.Path)
contractTestGenerators, err := getContractTestGenerators(relPackageDir, goMod.Module.Mod.Path, packageName)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/interchaintest/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ func getContractGenerators(idlSchema *schemas.IDLSchema, packageName, modulePath
return generators, nil
}

func getContractTestGenerators(relPackageDir, modulePath string) ([]*genny.Generator, error) {
func getContractTestGenerators(relPackageDir, modulePath, packageName string) ([]*genny.Generator, error) {
var generators []*genny.Generator

// contract test generator
ctg, err := interchaintestv8.NewGeneratorForContractTest(&interchaintestv8.ContractTestOptions{
ModulePath: modulePath,
RelPackageDir: relPackageDir,
PackageName: packageName,
})
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions templates/interchaintestv8/files/contract_test.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ func (s *ContractTestSuite) TestContract() {

// Add your test code here. For example, upload and instantiate a contract:
// This boilerplate may be moved to SetupSuite if it is common to all tests.
var contract *cwicacontroller.Contract
var contract *<%= PackageName %>.Contract
s.Run("UploadAndInstantiateContract", func() {
// Upload the contract code to the chain.
codeID, err := wasmd1.StoreContract(ctx, s.UserA.KeyName(), "./relative/path/to/your_contract.wasm")
s.Require().NoError(err)

// Instantiate the contract using contract helpers.
// This will an error if the instantiate message is invalid.
contract, err = cwicacontroller.Instantiate(ctx, s.UserA.KeyName(), codeID, "", wasmd1, cwicacontroller.InstantiateMsg{})
contract, err = <%= PackageName %>.Instantiate(ctx, s.UserA.KeyName(), codeID, "", wasmd1, <%= PackageName %>.InstantiateMsg{})
s.Require().NoError(err)

s.Require().NotEmpty(contract.Address)
Expand Down
2 changes: 2 additions & 0 deletions templates/interchaintestv8/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Options struct {
type ContractTestOptions struct {
ModulePath string
RelPackageDir string
PackageName string
}

// Validate that Options is usable.
Expand Down Expand Up @@ -60,5 +61,6 @@ func (opts *ContractTestOptions) plushContext() *plush.Context {
ctx := plush.NewContext()
ctx.Set("ModulePath", opts.ModulePath)
ctx.Set("RelPackageDir", opts.RelPackageDir)
ctx.Set("PackageName", opts.PackageName)
return ctx
}

0 comments on commit 5abac15

Please sign in to comment.