diff --git a/cli/contract_test.go b/cli/contract_test.go index 87fee79199..a70b8bd964 100644 --- a/cli/contract_test.go +++ b/cli/contract_test.go @@ -475,6 +475,9 @@ func TestCompileExamples(t *testing.T) { e := newExecutor(t, false) for _, info := range infos { + if !info.IsDir() { + continue + } t.Run(info.Name(), func(t *testing.T) { infos, err := ioutil.ReadDir(path.Join(examplePath, info.Name())) require.NoError(t, err) diff --git a/examples/my_wallet.json b/examples/my_wallet.json new file mode 100644 index 0000000000..320061f0e6 --- /dev/null +++ b/examples/my_wallet.json @@ -0,0 +1 @@ +{"version":"3.0","accounts":[{"address":"NX1yL5wDx3inK2qUVLRVaqCLUxYnAbv85S","key":"6PYUz1rNSwDf9ad1vxYbJyK93GrnnPBhr819HgSefMvgU1H9QxqVVCZQtN","label":"my_account","contract":{"script":"DCEDhEhWuuSSNuCc7nLsxQhI8nFlt+UfY3oP0/UkYmdH7G5BdHR2qg==","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isdefault":false}],"scrypt":{"n":16384,"r":8,"p":8},"extra":{"Tokens":null}} diff --git a/examples/my_wallet_test.go b/examples/my_wallet_test.go new file mode 100644 index 0000000000..35e14c56ef --- /dev/null +++ b/examples/my_wallet_test.go @@ -0,0 +1,25 @@ +package examples + +import ( + "testing" + + "github.com/nspcc-dev/neo-go/pkg/wallet" + "github.com/stretchr/testify/require" +) + +const ( + walletPath = "my_wallet.json" + walletPass = "qwerty" + accountLabel = "my_account" +) + +func TestDecryptMyWallet(t *testing.T) { + w, err := wallet.NewWalletFromFile(walletPath) + require.NoError(t, err) + require.Equal(t, 1, len(w.Accounts)) + require.Equal(t, accountLabel, w.Accounts[0].Label) + require.NoError(t, w.Accounts[0].Decrypt(walletPass)) + + // we need to keep the owner of the example contracts the same as the wallet account + require.Equal(t, "NX1yL5wDx3inK2qUVLRVaqCLUxYnAbv85S", w.Accounts[0].Address, "need to change `owner` in the example contracts") +} diff --git a/pkg/compiler/compiler_test.go b/pkg/compiler/compiler_test.go index 7ea0e8f656..e2c78754d9 100644 --- a/pkg/compiler/compiler_test.go +++ b/pkg/compiler/compiler_test.go @@ -45,6 +45,9 @@ func TestCompiler(t *testing.T) { infos, err := ioutil.ReadDir(examplePath) require.NoError(t, err) for _, info := range infos { + if !info.IsDir() { + continue + } infos, err := ioutil.ReadDir(path.Join(examplePath, info.Name())) require.NoError(t, err) require.False(t, len(infos) == 0, "detected smart contract folder with no contract in it")