diff --git a/.docker/wallets/wallet1.json b/.docker/wallets/wallet1.json index acb84d220..647eb851b 100644 --- a/.docker/wallets/wallet1.json +++ b/.docker/wallets/wallet1.json @@ -16,7 +16,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false }, { "address": "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq", @@ -41,7 +41,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false } ], "scrypt": { @@ -52,4 +52,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/.docker/wallets/wallet1_solo.json b/.docker/wallets/wallet1_solo.json index 160153fc8..7ebcf531a 100644 --- a/.docker/wallets/wallet1_solo.json +++ b/.docker/wallets/wallet1_solo.json @@ -16,7 +16,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false }, { "address": "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq", @@ -41,7 +41,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false }, { "address": "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP", @@ -58,7 +58,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false } ], "scrypt": { @@ -69,4 +69,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/.docker/wallets/wallet2.json b/.docker/wallets/wallet2.json index aea2f90cf..ad3e87906 100644 --- a/.docker/wallets/wallet2.json +++ b/.docker/wallets/wallet2.json @@ -16,7 +16,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false }, { "address": "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq", @@ -41,7 +41,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false } ], "scrypt": { @@ -52,4 +52,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/.docker/wallets/wallet3.json b/.docker/wallets/wallet3.json index 6695f393e..de6446cb5 100644 --- a/.docker/wallets/wallet3.json +++ b/.docker/wallets/wallet3.json @@ -16,7 +16,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false }, { "address": "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq", @@ -41,7 +41,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false } ], "scrypt": { @@ -52,4 +52,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/.docker/wallets/wallet4.json b/.docker/wallets/wallet4.json index 6603258fd..95d6f33d7 100644 --- a/.docker/wallets/wallet4.json +++ b/.docker/wallets/wallet4.json @@ -16,7 +16,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false }, { "address": "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq", @@ -41,7 +41,7 @@ "deployed": false }, "lock": false, - "isdefault": false + "isDefault": false } ], "scrypt": { @@ -52,4 +52,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/cli/nep_test/nep17_test.go b/cli/nep_test/nep17_test.go index f933e0559..f934c5d8d 100644 --- a/cli/nep_test/nep17_test.go +++ b/cli/nep_test/nep17_test.go @@ -19,19 +19,34 @@ import ( func TestNEP17Balance(t *testing.T) { e := testcli.NewExecutor(t, true) + + args := []string{ + "neo-go", "wallet", "nep17", "multitransfer", + "--rpc-endpoint", "http://" + e.RPC.Addresses()[0], + "--wallet", testcli.ValidatorWallet, + "--from", testcli.ValidatorAddr, + "GAS:" + testcli.TestWalletMultiAccount1 + ":1", + "NEO:" + testcli.TestWalletMultiAccount1 + ":10", + "GAS:" + testcli.TestWalletMultiAccount3 + ":3", + "--force", + } + e.In.WriteString("one\r") + e.Run(t, args...) + e.CheckTxPersisted(t) + cmdbalance := []string{"neo-go", "wallet", "nep17", "balance"} cmdbase := append(cmdbalance, "--rpc-endpoint", "http://"+e.RPC.Addresses()[0], - "--wallet", testcli.ValidatorWallet, + "--wallet", testcli.TestWalletMultiPath, ) - cmd := append(cmdbase, "--address", testcli.ValidatorAddr) + cmd := append(cmdbase, "--address", testcli.TestWalletMultiAccount1) t.Run("excessive parameters", func(t *testing.T) { e.RunWithError(t, append(cmd, "--token", "NEO", "gas")...) }) t.Run("NEO", func(t *testing.T) { - b, index := e.Chain.GetGoverningTokenBalance(testcli.ValidatorHash) + b, index := e.Chain.GetGoverningTokenBalance(testcli.TestWalletMultiAccount1Hash) checkResult := func(t *testing.T) { - e.CheckNextLine(t, "^\\s*Account\\s+"+testcli.ValidatorAddr) + e.CheckNextLine(t, "^\\s*Account\\s+"+testcli.TestWalletMultiAccount1) e.CheckNextLine(t, "^\\s*NEO:\\s+NeoToken \\("+e.Chain.GoverningTokenHash().StringLE()+"\\)") e.CheckNextLine(t, "^\\s*Amount\\s*:\\s*"+b.String()+"$") e.CheckNextLine(t, "^\\s*Updated\\s*:\\s*"+strconv.FormatUint(uint64(index), 10)) @@ -48,65 +63,53 @@ func TestNEP17Balance(t *testing.T) { }) t.Run("GAS", func(t *testing.T) { e.Run(t, append(cmd, "--token", "GAS")...) - e.CheckNextLine(t, "^\\s*Account\\s+"+testcli.ValidatorAddr) + e.CheckNextLine(t, "^\\s*Account\\s+"+testcli.TestWalletMultiAccount1) e.CheckNextLine(t, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") - b := e.Chain.GetUtilityTokenBalance(testcli.ValidatorHash) + b := e.Chain.GetUtilityTokenBalance(testcli.TestWalletMultiAccount1Hash) e.CheckNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(b.Int64()).String()+"$") }) t.Run("zero balance of known token", func(t *testing.T) { - e.Run(t, append(cmdbase, []string{"--token", "NEO"}...)...) - addr1, err := address.StringToUint160("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn") - require.NoError(t, err) - e.CheckNextLine(t, "^Account "+address.Uint160ToString(addr1)) + e.Run(t, append(cmdbase, []string{"--token", "NEO", "--address", testcli.TestWalletMultiAccount2}...)...) + e.CheckNextLine(t, "^Account "+testcli.TestWalletMultiAccount2) e.CheckNextLine(t, "^\\s*NEO:\\s+NeoToken \\("+e.Chain.GoverningTokenHash().StringLE()+"\\)") e.CheckNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(0).String()+"$") e.CheckNextLine(t, "^\\s*Updated:") - e.CheckNextLine(t, "^\\s*$") + e.CheckEOF(t) }) t.Run("all accounts", func(t *testing.T) { e.Run(t, cmdbase...) - addr1, err := address.StringToUint160("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn") - require.NoError(t, err) - e.CheckNextLine(t, "^Account "+address.Uint160ToString(addr1)) - e.CheckNextLine(t, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") - balance := e.Chain.GetUtilityTokenBalance(addr1) - e.CheckNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String()+"$") - e.CheckNextLine(t, "^\\s*Updated:") - e.CheckNextLine(t, "^\\s*$") - addr2, err := address.StringToUint160("NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq") - require.NoError(t, err) - e.CheckNextLine(t, "^Account "+address.Uint160ToString(addr2)) - e.CheckNextLine(t, "^\\s*$") - - addr3, err := address.StringToUint160("NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP") - require.NoError(t, err) - e.CheckNextLine(t, "^Account "+address.Uint160ToString(addr3)) + e.CheckNextLine(t, "^Account "+testcli.TestWalletMultiAccount1) // The order of assets is undefined. for i := 0; i < 2; i++ { line := e.GetNextLine(t) if strings.Contains(line, "GAS") { e.CheckLine(t, line, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") - balance = e.Chain.GetUtilityTokenBalance(addr3) + balance := e.Chain.GetUtilityTokenBalance(testcli.TestWalletMultiAccount1Hash) e.CheckNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String()+"$") e.CheckNextLine(t, "^\\s*Updated:") } else { - balance, index := e.Chain.GetGoverningTokenBalance(testcli.ValidatorHash) + balance, index := e.Chain.GetGoverningTokenBalance(testcli.TestWalletMultiAccount1Hash) e.CheckLine(t, line, "^\\s*NEO:\\s+NeoToken \\("+e.Chain.GoverningTokenHash().StringLE()+"\\)") e.CheckNextLine(t, "^\\s*Amount\\s*:\\s*"+balance.String()+"$") e.CheckNextLine(t, "^\\s*Updated\\s*:\\s*"+strconv.FormatUint(uint64(index), 10)) } } - e.CheckNextLine(t, "^\\s*$") - addr4, err := address.StringToUint160("NiFxRcC5Anz9pmqQyMHh5vamBUZDbRRRzA") // deployed verify.go contract - require.NoError(t, err) - e.CheckNextLine(t, "^Account "+address.Uint160ToString(addr4)) + + e.CheckNextLine(t, "^Account "+testcli.TestWalletMultiAccount2) + e.CheckNextLine(t, "^\\s*$") + + e.CheckNextLine(t, "^Account "+testcli.TestWalletMultiAccount3) + e.CheckNextLine(t, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") + balance := e.Chain.GetUtilityTokenBalance(testcli.TestWalletMultiAccount3Hash) + e.CheckNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String()+"$") + e.CheckNextLine(t, "^\\s*Updated:") e.CheckEOF(t) }) t.Run("Bad token", func(t *testing.T) { e.Run(t, append(cmd, "--token", "kek")...) - e.CheckNextLine(t, "^\\s*Account\\s+"+testcli.ValidatorAddr) + e.CheckNextLine(t, "^\\s*Account\\s+"+testcli.TestWalletMultiAccount1) e.CheckNextLine(t, `^\s*Can't find data for "kek" token\s*`) e.CheckEOF(t) }) diff --git a/cli/testdata/testwallet.json b/cli/testdata/testwallet.json index 13fcd48ad..8e089efe3 100644 --- a/cli/testdata/testwallet.json +++ b/cli/testdata/testwallet.json @@ -27,4 +27,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/cli/testdata/testwallet_multi.json b/cli/testdata/testwallet_multi.json new file mode 100644 index 000000000..8d1400b62 --- /dev/null +++ b/cli/testdata/testwallet_multi.json @@ -0,0 +1,64 @@ +{ + "version": "1.0", + "accounts": [ + { + "address": "NgHcPxgEKZQV4QBedzyASJrgiANhJqBVLw", + "key": "6PYTbVq2P3AJQwWU5SFMKLjHYco7QABtNRo4ZvLvXhyaYjwMcuZm6xKokT", + "label": "one", + "contract": { + "script": "DCECnmSGVirDOqMr57EHaYz0YMTjaHQtO9FQYu8DMTCDw6VBVuezJw==", + "parameters": [ + { + "name": "parameter0", + "type": "Signature" + } + ], + "deployed": false + }, + "lock": false, + "isDefault": false + }, + { + "address": "NLvHRfKAifjio2z9HiwLo9ZnpRPHUbAHgH", + "key": "6PYUjQ8TgR3cduEpG5niUNuPEWi3tYiQsnC4Jha9nGAJ6tAQGUmcrZXsLF", + "label": "two", + "contract": { + "script": "DCECgk91c1ABAX3A1uJNnxhGlp7NwUJScwJzJhrsYrXIbgNBVuezJw==", + "parameters": [ + { + "name": "parameter0", + "type": "Signature" + } + ], + "deployed": false + }, + "lock": false, + "isDefault": false + }, + { + "address": "NcDfG8foJx79XSihcDDrx1df7cHAoJBfXj", + "key": "6PYRkUQKWFrTovHyeQZ7X4nWoDXKohtFRKW51LiCz317pwCjmB1cVwpcxz", + "label": "three", + "contract": { + "script": "DCEC9v0ZqBg8f4jJX9WR891M0bazf0FYTNu7MEgpSHrb9CVBVuezJw==", + "parameters": [ + { + "name": "parameter0", + "type": "Signature" + } + ], + "deployed": false + }, + "lock": false, + "isDefault": false + } + ], + "scrypt": { + "n": 2, + "r": 1, + "p": 1 + }, + "extra": { + "Tokens": null + } +} \ No newline at end of file diff --git a/cli/testdata/wallet1_solo.json b/cli/testdata/wallet1_solo.json index a862c61d3..28dfffb8a 100644 --- a/cli/testdata/wallet1_solo.json +++ b/cli/testdata/wallet1_solo.json @@ -65,6 +65,7 @@ "key": "6PYSATFztBa3CHjSR6sLAKungUEAbQUCVE16KzmaQQ38gLeYGZ9Knd5mGv", "label": "verify", "contract": { + "script": "VwEAEUBXAANA", "parameters": [], "deployed": true }, @@ -80,4 +81,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/cli/wallet/testdata/testwallet_NEO3.json b/cli/wallet/testdata/testwallet_NEO3.json index 320a794ea..647eb851b 100644 --- a/cli/wallet/testdata/testwallet_NEO3.json +++ b/cli/wallet/testdata/testwallet_NEO3.json @@ -52,4 +52,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/examples/my_wallet.json b/examples/my_wallet.json index 982fa3abe..0c6ad209f 100644 --- a/examples/my_wallet.json +++ b/examples/my_wallet.json @@ -27,4 +27,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/internal/testcli/executor.go b/internal/testcli/executor.go index 5fec5e06a..877b250e0 100644 --- a/internal/testcli/executor.go +++ b/internal/testcli/executor.go @@ -48,6 +48,11 @@ const ( TestWalletPath = "../testdata/testwallet.json" TestWalletAccount = "Nfyz4KcsgYepRJw1W5C2uKCi6QWKf7v6gG" + TestWalletMultiPath = "../testdata/testwallet_multi.json" + TestWalletMultiAccount1 = "NgHcPxgEKZQV4QBedzyASJrgiANhJqBVLw" + TestWalletMultiAccount2 = "NLvHRfKAifjio2z9HiwLo9ZnpRPHUbAHgH" + TestWalletMultiAccount3 = "NcDfG8foJx79XSihcDDrx1df7cHAoJBfXj" + ValidatorWallet = "../testdata/wallet1_solo.json" ValidatorPass = "one" ) @@ -55,6 +60,10 @@ const ( var ( ValidatorHash, _ = address.StringToUint160(ValidatorAddr) ValidatorPriv, _ = keys.NewPrivateKeyFromWIF(ValidatorWIF) + + TestWalletMultiAccount1Hash, _ = address.StringToUint160(TestWalletMultiAccount1) + TestWalletMultiAccount2Hash, _ = address.StringToUint160(TestWalletMultiAccount2) + TestWalletMultiAccount3Hash, _ = address.StringToUint160(TestWalletMultiAccount3) ) // Executor represents context for a test instance. diff --git a/pkg/consensus/testdata/wallet1.json b/pkg/consensus/testdata/wallet1.json index 320a794ea..647eb851b 100644 --- a/pkg/consensus/testdata/wallet1.json +++ b/pkg/consensus/testdata/wallet1.json @@ -52,4 +52,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/pkg/consensus/testdata/wallet2.json b/pkg/consensus/testdata/wallet2.json index bff5db221..ad3e87906 100644 --- a/pkg/consensus/testdata/wallet2.json +++ b/pkg/consensus/testdata/wallet2.json @@ -52,4 +52,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/pkg/consensus/testdata/wallet3.json b/pkg/consensus/testdata/wallet3.json index c0f6aba87..de6446cb5 100644 --- a/pkg/consensus/testdata/wallet3.json +++ b/pkg/consensus/testdata/wallet3.json @@ -52,4 +52,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/pkg/consensus/testdata/wallet4.json b/pkg/consensus/testdata/wallet4.json index b4a9a319b..95d6f33d7 100644 --- a/pkg/consensus/testdata/wallet4.json +++ b/pkg/consensus/testdata/wallet4.json @@ -52,4 +52,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/pkg/services/notary/testdata/notary1.json b/pkg/services/notary/testdata/notary1.json index 578f77e62..53e61ff34 100644 --- a/pkg/services/notary/testdata/notary1.json +++ b/pkg/services/notary/testdata/notary1.json @@ -61,4 +61,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/pkg/services/notary/testdata/notary2.json b/pkg/services/notary/testdata/notary2.json index 2536b459c..9711209ad 100644 --- a/pkg/services/notary/testdata/notary2.json +++ b/pkg/services/notary/testdata/notary2.json @@ -27,4 +27,4 @@ "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/pkg/services/oracle/testdata/oracle1.json b/pkg/services/oracle/testdata/oracle1.json index 14f813f73..4d082e21d 100644 --- a/pkg/services/oracle/testdata/oracle1.json +++ b/pkg/services/oracle/testdata/oracle1.json @@ -3,7 +3,7 @@ "accounts": [ { "address": "NLUCkBS5dtk1h5cedgFoVXqeoCW2UiYNrZ", - "key": "6PYVFexrF2CvxJwx3xpoPchHWJpkrcXy5FZjuXckpArgApVm6AEpQwCuKw", + "key": "6PYVFexrFDhQ9BewmNFTM8rL5qyq6Zqp3hL2QPZCchJiZQhkctAvUWS3Xa", "label": "", "contract": { "script": "DCEDNxK01e1DnGA+TiGU3H4DKUuGliSz89/NuZCbVvA2u0xBVuezJw==", @@ -20,11 +20,11 @@ } ], "scrypt": { - "n": 16384, - "r": 8, - "p": 8 + "n": 2, + "r": 1, + "p": 1 }, "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/pkg/services/oracle/testdata/oracle2.json b/pkg/services/oracle/testdata/oracle2.json index 452e28d79..cc4a14de8 100644 --- a/pkg/services/oracle/testdata/oracle2.json +++ b/pkg/services/oracle/testdata/oracle2.json @@ -3,7 +3,7 @@ "accounts": [ { "address": "NUkatH1cgvBeQyDwfyEjTqZRgjmXC1d23A", - "key": "6PYNvsB8P7Ge5SHth9Ui9ikgkupTfED1g7Ec39gn2YDuuM4LFgQgG4j4i3", + "key": "6PYNvsB8NJ3RggwkVxuh8KP6fxuyf9J5bcwrKkLRNaPoea661eEHZyTeVb", "label": "", "contract": { "script": "DCEDEXzwIl4Jhvsj98GYIPFFiedeb1QdP8T79uSBSDNsisxBVuezJw==", @@ -20,11 +20,11 @@ } ], "scrypt": { - "n": 16384, - "r": 8, - "p": 8 + "n": 2, + "r": 1, + "p": 1 }, "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/pkg/wallet/regenerate_test.go b/pkg/wallet/regenerate_test.go index 5dfc919f8..15cdf7fc9 100644 --- a/pkg/wallet/regenerate_test.go +++ b/pkg/wallet/regenerate_test.go @@ -29,6 +29,10 @@ var ( } passwords = []string{"one", "two", "three", "four"} + + // naiveScrypt is naive scrypt parameters used for testing wallets to save + // time on accounts decryption. + naiveScrypt = keys.ScryptParams{N: 2, R: 1, P: 1} ) func getKeys(t *testing.T) []*keys.PublicKey { @@ -42,10 +46,14 @@ func getKeys(t *testing.T) []*keys.PublicKey { return pubs } -func getAccount(t *testing.T, wif, pass string) *Account { +func getNEP2Account(t *testing.T, wif, pass string) *Account { return getAccountWithScrypt(t, wif, pass, keys.NEP2ScryptParams()) } +func getTestingAccount(t *testing.T, wif, pass string) *Account { + return getAccountWithScrypt(t, wif, pass, naiveScrypt) +} + func getAccountWithScrypt(t *testing.T, wif, pass string, scrypt keys.ScryptParams) *Account { acc, err := NewAccountFromWIF(wif) require.NoError(t, err) @@ -59,24 +67,24 @@ func TestRegenerateSoloWallet(t *testing.T) { } walletPath := filepath.Join(dockerWalletDir, "wallet1_solo.json") wif := privnetWIFs[0] - acc1 := getAccount(t, wif, "one") - acc2 := getAccount(t, wif, "one") + acc1 := getNEP2Account(t, wif, "one") + acc2 := getNEP2Account(t, wif, "one") require.NoError(t, acc2.ConvertMultisig(3, getKeys(t))) - acc3 := getAccount(t, wif, "one") + acc3 := getNEP2Account(t, wif, "one") require.NoError(t, acc3.ConvertMultisig(1, keys.PublicKeys{getKeys(t)[0]})) - createWallet(t, walletPath, acc1, acc2, acc3) + createNEP2Wallet(t, walletPath, acc1, acc2, acc3) } func regenerateWallets(t *testing.T, dir string) { pubs := getKeys(t) for i := range privnetWIFs { - acc1 := getAccount(t, privnetWIFs[i], passwords[i]) - acc2 := getAccount(t, privnetWIFs[i], passwords[i]) + acc1 := getNEP2Account(t, privnetWIFs[i], passwords[i]) + acc2 := getNEP2Account(t, privnetWIFs[i], passwords[i]) require.NoError(t, acc2.ConvertMultisig(3, pubs)) - createWallet(t, filepath.Join(dir, fmt.Sprintf("wallet%d.json", i+1)), acc1, acc2) + createNEP2Wallet(t, filepath.Join(dir, fmt.Sprintf("wallet%d.json", i+1)), acc1, acc2) } } @@ -99,17 +107,17 @@ func TestRegenerateWalletTestdata(t *testing.T) { } const walletDir = "./testdata/" - acc1 := getAccount(t, privnetWIFs[0], "one") - acc2 := getAccount(t, privnetWIFs[0], "one") + acc1 := getTestingAccount(t, privnetWIFs[0], "one") + acc2 := getTestingAccount(t, privnetWIFs[0], "one") pubs := getKeys(t) require.NoError(t, acc2.ConvertMultisig(3, pubs)) - acc3 := getAccount(t, privnetWIFs[1], "two") + acc3 := getTestingAccount(t, privnetWIFs[1], "two") acc3.Default = true - createWallet(t, filepath.Join(walletDir, "wallet1.json"), acc1, acc2) + createTestingWallet(t, filepath.Join(walletDir, "wallet1.json"), acc1, acc2) - createWallet(t, filepath.Join(walletDir, "wallet2.json"), acc1, acc2, acc3) + createTestingWallet(t, filepath.Join(walletDir, "wallet2.json"), acc1, acc2, acc3) } func TestRegenerateNotaryWallets(t *testing.T) { @@ -123,15 +131,13 @@ func TestRegenerateNotaryWallets(t *testing.T) { acc4WIF = "L1ioz93TNt6Nu1aoMpZQ4zgdtgC8ZvJMC6pyHFkrovdR3SFwbn6n" ) var walletDir = filepath.Join("..", "services", "notary", "testdata") + acc1 := getAccountWithScrypt(t, acc1WIF, "one", naiveScrypt) + acc2 := getAccountWithScrypt(t, acc2WIF, "one", naiveScrypt) + acc3 := getAccountWithScrypt(t, acc3WIF, "four", naiveScrypt) + createTestingWallet(t, filepath.Join(walletDir, "notary1.json"), acc1, acc2, acc3) - scryptParams := keys.ScryptParams{N: 2, R: 1, P: 1} - acc1 := getAccountWithScrypt(t, acc1WIF, "one", scryptParams) - acc2 := getAccountWithScrypt(t, acc2WIF, "one", scryptParams) - acc3 := getAccountWithScrypt(t, acc3WIF, "four", scryptParams) - createWallet(t, filepath.Join(walletDir, "notary1.json"), acc1, acc2, acc3) - - acc4 := getAccountWithScrypt(t, acc4WIF, "two", scryptParams) - createWallet(t, filepath.Join(walletDir, "notary2.json"), acc4) + acc4 := getAccountWithScrypt(t, acc4WIF, "two", naiveScrypt) + createTestingWallet(t, filepath.Join(walletDir, "notary2.json"), acc4) } func TestRegenerateOracleWallets(t *testing.T) { @@ -144,11 +150,11 @@ func TestRegenerateOracleWallets(t *testing.T) { acc2WIF = "KyA8z2MyLCSjJFG3F4SUp85CZ4WJm4qgWihFJZFEDYGEyw8oGcEP" ) - acc1 := getAccount(t, acc1WIF, "one") - createWallet(t, filepath.Join(walletDir, "oracle1.json"), acc1) + acc1 := getTestingAccount(t, acc1WIF, "one") + createTestingWallet(t, filepath.Join(walletDir, "oracle1.json"), acc1) - acc2 := getAccount(t, acc2WIF, "two") - createWallet(t, filepath.Join(walletDir, "oracle2.json"), acc2) + acc2 := getTestingAccount(t, acc2WIF, "two") + createTestingWallet(t, filepath.Join(walletDir, "oracle2.json"), acc2) } func TestRegenerateExamplesWallet(t *testing.T) { @@ -160,9 +166,9 @@ func TestRegenerateExamplesWallet(t *testing.T) { acc1WIF = "L46dn46AMZY7NQGZHemAdgcMabKon85eme45hgQkAUQBiRacY8MB" ) - acc1 := getAccount(t, acc1WIF, "qwerty") + acc1 := getNEP2Account(t, acc1WIF, "qwerty") acc1.Label = "my_account" - createWallet(t, walletPath, acc1) + createNEP2Wallet(t, walletPath, acc1) } func TestRegenerateCLITestwallet(t *testing.T) { @@ -174,9 +180,32 @@ func TestRegenerateCLITestwallet(t *testing.T) { accWIF = "L23LrQNWELytYLvb5c6dXBDdF2DNPL9RRNWPqppv3roxacSnn8CN" ) - acc := getAccountWithScrypt(t, accWIF, "testpass", keys.ScryptParams{N: 2, R: 1, P: 1}) + acc := getAccountWithScrypt(t, accWIF, "testpass", naiveScrypt) acc.Label = "kek" - createWallet(t, walletPath, acc) + createTestingWallet(t, walletPath, acc) +} + +func TestRegenerateCLITestwalletMulti(t *testing.T) { + if !regenerate { + return + } + const ( + walletPath = "../../cli/testdata/testwallet_multi.json" + accWIF1 = "L2NZQ84s8SuUfyJmtjs7J5a2pZFEVQVVRYDtNsQEyB4RjHnpkorr" + pass1 = "one" + accWIF2 = "L4pSqPmvbghcM8NY14CNSUzkK92VmSFLKNwAh9TqLqFhTZkxZgsP" + pass2 = "two" + accWIF3 = "L1eNtPQA8bALqvSgGMNpNR3EYFR15WeNdCZDuiwWYcQ6Q6FfuVro" + pass3 = "three" + ) + + acc1 := getAccountWithScrypt(t, accWIF1, pass1, naiveScrypt) + acc1.Label = pass1 + acc2 := getAccountWithScrypt(t, accWIF2, pass2, naiveScrypt) + acc2.Label = pass2 + acc3 := getAccountWithScrypt(t, accWIF3, pass3, naiveScrypt) + acc3.Label = pass3 + createTestingWallet(t, walletPath, acc1, acc2, acc3) } func TestRegenerateCLITestwallet_NEO3(t *testing.T) { @@ -186,15 +215,28 @@ func TestRegenerateCLITestwallet_NEO3(t *testing.T) { const walletPath = "../../cli/wallet/testdata/testwallet_NEO3.json" pubs := getKeys(t) - acc1 := getAccount(t, privnetWIFs[0], passwords[0]) - acc2 := getAccount(t, privnetWIFs[0], passwords[0]) + acc1 := getNEP2Account(t, privnetWIFs[0], passwords[0]) + acc2 := getNEP2Account(t, privnetWIFs[0], passwords[0]) require.NoError(t, acc2.ConvertMultisig(3, pubs)) - createWallet(t, walletPath, acc1, acc2) + createNEP2Wallet(t, walletPath, acc1, acc2) } -func createWallet(t *testing.T, path string, accs ...*Account) { +// createNEP2Wallet creates wallet with provided accounts and NEP2 scrypt parameters. +func createNEP2Wallet(t *testing.T, path string, accs ...*Account) { + createWallet(t, path, keys.NEP2ScryptParams(), accs...) +} + +// createTestingWallet creates wallet with provided accounts and scrypt parameters with +// low values which can be used for testing to save time on accounts decryption. +func createTestingWallet(t *testing.T, path string, accs ...*Account) { + createWallet(t, path, naiveScrypt, accs...) +} + +func createWallet(t *testing.T, path string, scryptParams keys.ScryptParams, accs ...*Account) { w, err := NewWallet(path) require.NoError(t, err) + w.Scrypt = scryptParams + if len(accs) == 0 { t.Fatal("provide at least 1 account") } @@ -215,17 +257,16 @@ func TestRegenerateCLIWallet1_solo(t *testing.T) { verifyManifestPath = "../../cli/smartcontract/testdata/verify.manifest.json" ) - scrypt := keys.ScryptParams{N: 2, R: 1, P: 1} wif := privnetWIFs[0] - acc1 := getAccountWithScrypt(t, wif, "one", scrypt) + acc1 := getAccountWithScrypt(t, wif, "one", naiveScrypt) acc1.Default = true - acc2 := getAccountWithScrypt(t, wif, "one", scrypt) + acc2 := getAccountWithScrypt(t, wif, "one", naiveScrypt) require.NoError(t, acc2.ConvertMultisig(3, getKeys(t))) - acc3 := getAccountWithScrypt(t, wif, "one", scrypt) + acc3 := getAccountWithScrypt(t, wif, "one", naiveScrypt) require.NoError(t, acc3.ConvertMultisig(1, keys.PublicKeys{getKeys(t)[0]})) - acc4 := getAccountWithScrypt(t, verifyWIF, "pass", scrypt) // deployed verify.go contract + acc4 := getAccountWithScrypt(t, verifyWIF, "pass", naiveScrypt) // deployed verify.go contract f, err := os.ReadFile(verifyNEFPath) require.NoError(t, err) nefFile, err := nef.FileFromBytes(f) @@ -242,5 +283,5 @@ func TestRegenerateCLIWallet1_solo(t *testing.T) { Parameters: []ContractParam{}, } acc4.Label = "verify" - createWallet(t, walletPath, acc1, acc2, acc3, acc4) + createTestingWallet(t, walletPath, acc1, acc2, acc3, acc4) } diff --git a/pkg/wallet/testdata/wallet1.json b/pkg/wallet/testdata/wallet1.json index 320a794ea..4ae513039 100644 --- a/pkg/wallet/testdata/wallet1.json +++ b/pkg/wallet/testdata/wallet1.json @@ -3,7 +3,7 @@ "accounts": [ { "address": "Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", - "key": "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY", + "key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR", "label": "", "contract": { "script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBVuezJw==", @@ -20,7 +20,7 @@ }, { "address": "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq", - "key": "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY", + "key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR", "label": "", "contract": { "script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6", @@ -45,11 +45,11 @@ } ], "scrypt": { - "n": 16384, - "r": 8, - "p": 8 + "n": 2, + "r": 1, + "p": 1 }, "extra": { "Tokens": null } -} +} \ No newline at end of file diff --git a/pkg/wallet/testdata/wallet2.json b/pkg/wallet/testdata/wallet2.json index ba3f2253d..fdf38bf8e 100644 --- a/pkg/wallet/testdata/wallet2.json +++ b/pkg/wallet/testdata/wallet2.json @@ -3,7 +3,7 @@ "accounts": [ { "address": "Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", - "key": "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY", + "key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR", "label": "", "contract": { "script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBVuezJw==", @@ -20,7 +20,7 @@ }, { "address": "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq", - "key": "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY", + "key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR", "label": "", "contract": { "script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6", @@ -45,7 +45,7 @@ }, { "address": "NMUedC8TSV2rE17wGguSvPk9XcmHSaT275", - "key": "6PYSYoZaxqDu5vqvm7yUFT3sPJJFwyLyYDnp8zwj1YVPcBWxacz64bNX59", + "key": "6PYSYoZawnSyrpXJTu9aN7uXFd1HTisrtimxMs7xkEnqe2zztLrMvFZCtT", "label": "", "contract": { "script": "DCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG5BVuezJw==", @@ -62,11 +62,11 @@ } ], "scrypt": { - "n": 16384, - "r": 8, - "p": 8 + "n": 2, + "r": 1, + "p": 1 }, "extra": { "Tokens": null } -} +} \ No newline at end of file