-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip new ibcmodule in progress * further IBC module work base * self-ibc generation * fix proto & stuff * fix * wip * working demo * complete ibc demo * test: module generation for * simplify module logic * fixes & typos * fix: docs * update docs :D
- Loading branch information
1 parent
158a59d
commit 288f5f3
Showing
57 changed files
with
6,984 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,10 @@ var ( | |
} | ||
) | ||
|
||
func NewRootCmd() *cobra.Command { | ||
return rootCmd | ||
} | ||
|
||
func main() { | ||
outOfDateChecker() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package main_test | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"os" | ||
"path" | ||
"testing" | ||
|
||
main "github.com/rollchains/spawn/cmd/spawn" | ||
"github.com/rollchains/spawn/spawn" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestModuleGeneration(t *testing.T) { | ||
cwd, err := os.Getwd() | ||
require.NoError(t, err) | ||
|
||
cfg := spawn.NewChainConfig{ | ||
ProjectName: "default", | ||
Bech32Prefix: "cosmos", | ||
HomeDir: ".default", | ||
BinDaemon: main.RandStringBytes(6) + "d", | ||
Denom: "token" + main.RandStringBytes(3), | ||
GithubOrg: main.RandStringBytes(15), | ||
IgnoreGitInit: false, | ||
DisabledModules: []string{"explorer"}, | ||
Logger: main.Logger, | ||
} | ||
|
||
type mc struct { | ||
Name string | ||
Args []string | ||
OutputContains string | ||
} | ||
|
||
mcs := []mc{ | ||
{ | ||
Name: "ibcmodule", | ||
Args: []string{"new", "myibc", "--ibc-module"}, | ||
}, | ||
{ | ||
Name: "ibcmiddleware", | ||
Args: []string{"new", "myibcmw", "--ibc-middleware"}, | ||
}, | ||
{ | ||
Name: "standard", | ||
Args: []string{"new", "standard"}, | ||
}, | ||
} | ||
|
||
for _, c := range mcs { | ||
c := c | ||
t.Run(c.Name, func(t *testing.T) { | ||
name := "spawnmoduleunittest" + c.Name | ||
|
||
cfg.ProjectName = name | ||
cfg.HomeDir = "." + name | ||
fmt.Println("=====\nName", name) | ||
|
||
dirPath := path.Join(cwd, name) | ||
require.NoError(t, os.RemoveAll(name)) | ||
|
||
require.NoError(t, cfg.ValidateAndRun(false), "failed to generate proper chain") | ||
|
||
// move to new repo | ||
require.NoError(t, os.Chdir(dirPath)) | ||
|
||
cmd := main.ModuleCmd() | ||
b := bytes.NewBufferString("") | ||
cmd.SetOut(b) | ||
cmd.SetErr(b) | ||
cmd.SetArgs(c.Args) | ||
cmd.Execute() | ||
// out, err := io.ReadAll(b) | ||
// if err != nil { | ||
// t.Fatal(err) | ||
// } | ||
|
||
// TODO: this is not being read from. Fix. | ||
// require.Contains(t, string(out), c.OutputContains, "output: "+string(out)) | ||
|
||
// validate the go source is good | ||
main.AssertValidGeneration(t, dirPath, nil, nil, cfg) | ||
|
||
require.NoError(t, os.Chdir(cwd)) | ||
require.NoError(t, os.RemoveAll(name)) | ||
}) | ||
} | ||
} |
Oops, something went wrong.