Skip to content

Commit

Permalink
examples: add my_wallet.json
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaShaleva committed Mar 22, 2021
1 parent 2f07d1a commit 8a76a7f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions examples/my_wallet.json
Original file line number Diff line number Diff line change
@@ -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}}
25 changes: 25 additions & 0 deletions examples/my_wallet_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
3 changes: 3 additions & 0 deletions pkg/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 8a76a7f

Please sign in to comment.