mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
*: regenerate test wallets with resources-friendly scrypt parameters
This commit is contained in:
parent
50296975e2
commit
472a44a464
6 changed files with 141 additions and 86 deletions
8
cli/testdata/testwallet.json
vendored
8
cli/testdata/testwallet.json
vendored
|
@ -3,7 +3,7 @@
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "Nfyz4KcsgYepRJw1W5C2uKCi6QWKf7v6gG",
|
"address": "Nfyz4KcsgYepRJw1W5C2uKCi6QWKf7v6gG",
|
||||||
"key": "6PYVjvHy8n4suq81uxkWqriiffKWFpTFPve57HdzWdDhpYUUYRUTai1jZS",
|
"key": "6PYVjvHyAFQPXCU3PNsiRbF1RxEyyrT4PqLbSEEZcyYDFAMpSxPZnuRznY",
|
||||||
"label": "kek",
|
"label": "kek",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECl3UyEIq6T5RRIXS6z4tNdZPTzQ7NvXyx7FwK05d9UyZBVuezJw==",
|
"script": "DCECl3UyEIq6T5RRIXS6z4tNdZPTzQ7NvXyx7FwK05d9UyZBVuezJw==",
|
||||||
|
@ -20,9 +20,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scrypt": {
|
"scrypt": {
|
||||||
"n": 16384,
|
"n": 2,
|
||||||
"r": 8,
|
"r": 1,
|
||||||
"p": 8
|
"p": 1
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"Tokens": null
|
"Tokens": null
|
||||||
|
|
60
cli/testdata/wallet1_solo.json
vendored
60
cli/testdata/wallet1_solo.json
vendored
|
@ -1,28 +1,27 @@
|
||||||
{
|
{
|
||||||
"extra" : {
|
"version": "3.0",
|
||||||
"Tokens" : null
|
|
||||||
},
|
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
|
"address": "Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn",
|
||||||
|
"key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR",
|
||||||
"label": "",
|
"label": "",
|
||||||
"key" : "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY",
|
|
||||||
"lock" : false,
|
|
||||||
"isDefault" : true,
|
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBVuezJw==",
|
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBVuezJw==",
|
||||||
"deployed" : false,
|
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
"type": "Signature"
|
"type": "Signature"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"deployed": false
|
||||||
},
|
},
|
||||||
"address" : "Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn"
|
"lock": false,
|
||||||
|
"isDefault": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lock" : false,
|
"address": "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq",
|
||||||
"isDefault" : false,
|
"key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR",
|
||||||
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
@ -35,50 +34,51 @@
|
||||||
"type": "Signature"
|
"type": "Signature"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type" : "Signature",
|
"name": "parameter2",
|
||||||
"name" : "parameter2"
|
"type": "Signature"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"deployed": false
|
"deployed": false
|
||||||
},
|
},
|
||||||
"address" : "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq",
|
"lock": false,
|
||||||
"label" : "",
|
"isDefault": false
|
||||||
"key" : "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lock" : false,
|
"address": "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP",
|
||||||
"isDefault" : false,
|
"key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR",
|
||||||
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
|
"script": "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEUGe0Nw6",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
"type": "Signature"
|
"type": "Signature"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"deployed" : false,
|
"deployed": false
|
||||||
"script" : "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEUGe0Nw6"
|
|
||||||
},
|
},
|
||||||
"address" : "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP",
|
"lock": false,
|
||||||
"label" : "",
|
"isDefault": false
|
||||||
"key" : "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NU4CTk9H2fgNCuC3ZPqX4LjUX3MHt3Rh6p",
|
"address": "NU4CTk9H2fgNCuC3ZPqX4LjUX3MHt3Rh6p",
|
||||||
|
"key": "6PYSATFztBa3CHjSR6sLAKungUEAbQUCVE16KzmaQQ38gLeYGZ9Knd5mGv",
|
||||||
|
"label": "verify",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EdsgQFcAA0BXAQR4eXp7VBTAcAwOT25ORVAxMVBheW1lbnRoUEGVAW9hIUA=",
|
"script": "EdsgQFcAA0BXAQR4eXp7VBTAcAwOT25ORVAxMVBheW1lbnRoUEGVAW9hIUA=",
|
||||||
"parameters": [],
|
"parameters": [],
|
||||||
"deployed": true
|
"deployed": true
|
||||||
},
|
},
|
||||||
"lock": false,
|
"lock": false,
|
||||||
"isDefault" : false,
|
"isDefault": false
|
||||||
"key" : "6PYSATFzuRXXUeq7tMDyA1AGxWdVcm7ftbkqtGBt69WJBapT1tkwjp1zpx",
|
|
||||||
"label" : "acc"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version" : "3.0",
|
|
||||||
"scrypt": {
|
"scrypt": {
|
||||||
"r" : 8,
|
"n": 2,
|
||||||
"n" : 16384,
|
"r": 1,
|
||||||
"p" : 8
|
"p": 1
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"Tokens": null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ func TestWalletExport(t *testing.T) {
|
||||||
"--wallet", validatorWallet, validatorAddr)
|
"--wallet", validatorWallet, validatorAddr)
|
||||||
line, err := e.Out.ReadString('\n')
|
line, err := e.Out.ReadString('\n')
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
enc, err := keys.NEP2Encrypt(validatorPriv, "one", keys.NEP2ScryptParams())
|
enc, err := keys.NEP2Encrypt(validatorPriv, "one", keys.ScryptParams{N: 2, R: 1, P: 1}) // these params used in validator wallet for better resources consumption
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, enc, strings.TrimSpace(line))
|
require.Equal(t, enc, strings.TrimSpace(line))
|
||||||
})
|
})
|
||||||
|
|
12
pkg/services/notary/testdata/notary1.json
vendored
12
pkg/services/notary/testdata/notary1.json
vendored
|
@ -3,7 +3,7 @@
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "Nbruchf1SGfar3sN4cPr1UG1bWqADrN5sh",
|
"address": "Nbruchf1SGfar3sN4cPr1UG1bWqADrN5sh",
|
||||||
"key": "6PYRC8sNNB5rVx96ezh6Eefw8JcdQPRBfHx7hfe251m4bwHQnH2cZbcRk8",
|
"key": "6PYRC8sNMsyDRf8wVvQEpBJa5JXKbQ1SXGaXTvzW8u8mcpBTYs6E6kk1a6",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCEDm5PmbOfVPmYXTSVW903XnOhhNBTsF9oDlVYusIH/ui1BVuezJw==",
|
"script": "DCEDm5PmbOfVPmYXTSVW903XnOhhNBTsF9oDlVYusIH/ui1BVuezJw==",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NiYvEoR2FTD8FmGXtg1WMhkaTS9A6VH7YV",
|
"address": "NiYvEoR2FTD8FmGXtg1WMhkaTS9A6VH7YV",
|
||||||
"key": "6PYMecvacj5qTSB771Q9k4wfqTRK4SXSQhmDsDAxZxBgEVJf4BsnrgrQYS",
|
"key": "6PYMecvacKctbTeqApPGuukViQ2bbvFG4qNNm7VJS4oGzTF3rpptsbDaKd",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCEDHRWEIGXHCwUU2Fc7B0qrYPezXR0sfdEduRExyzIKVC9BVuezJw==",
|
"script": "DCEDHRWEIGXHCwUU2Fc7B0qrYPezXR0sfdEduRExyzIKVC9BVuezJw==",
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NcPWfiU7bJkUpBruEQcGRyo91bTWijcUXY",
|
"address": "NcPWfiU7bJkUpBruEQcGRyo91bTWijcUXY",
|
||||||
"key": "6PYWH6sS2JVshBA5ijMAT1CtFbs9LcLuthYoR4eZMD8TyXShD1c2zLsfjC",
|
"key": "6PYWH6sS3VzGWq6K8oSoiRKDKSKkHHWhjHn9zQ8Qs2Zn9KboqWzseieXj2",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECmUfs/gqKHd3AdJm5+Ev6zkubV8pP8DZzgu8+t5WdphJBVuezJw==",
|
"script": "DCECmUfs/gqKHd3AdJm5+Ev6zkubV8pP8DZzgu8+t5WdphJBVuezJw==",
|
||||||
|
@ -54,9 +54,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scrypt": {
|
"scrypt": {
|
||||||
"n": 16384,
|
"n": 2,
|
||||||
"r": 8,
|
"r": 1,
|
||||||
"p": 8
|
"p": 1
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"Tokens": null
|
"Tokens": null
|
||||||
|
|
8
pkg/services/notary/testdata/notary2.json
vendored
8
pkg/services/notary/testdata/notary2.json
vendored
|
@ -3,7 +3,7 @@
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NaVp3ZxwZWA84DRewRjnBLFstaeBuVMKwR",
|
"address": "NaVp3ZxwZWA84DRewRjnBLFstaeBuVMKwR",
|
||||||
"key": "6PYK1JEBNRL1jnqpD2Vct9sa5gjSfU5p42zavZBmWmKWR8oKvS5mPzcvqm",
|
"key": "6PYK1JEBNB9ndo7HmC9mXeNbdPi9NGb81C2tJrsTw4PBkcT64X6SQhnxHq",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECIcKj0GFdv4b1NZrw9X6zLNLWzmNKAxtw6olIMZxpPRRBVuezJw==",
|
"script": "DCECIcKj0GFdv4b1NZrw9X6zLNLWzmNKAxtw6olIMZxpPRRBVuezJw==",
|
||||||
|
@ -20,9 +20,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scrypt": {
|
"scrypt": {
|
||||||
"n": 16384,
|
"n": 2,
|
||||||
"r": 8,
|
"r": 1,
|
||||||
"p": 8
|
"p": 1
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"Tokens": null
|
"Tokens": null
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
package wallet
|
package wallet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,9 +43,13 @@ func getKeys(t *testing.T) []*keys.PublicKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAccount(t *testing.T, wif, pass string) *Account {
|
func getAccount(t *testing.T, wif, pass string) *Account {
|
||||||
|
return getAccountWithScrypt(t, wif, pass, keys.NEP2ScryptParams())
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAccountWithScrypt(t *testing.T, wif, pass string, scrypt keys.ScryptParams) *Account {
|
||||||
acc, err := NewAccountFromWIF(wif)
|
acc, err := NewAccountFromWIF(wif)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, acc.Encrypt(pass, keys.NEP2ScryptParams()))
|
require.NoError(t, acc.Encrypt(pass, scrypt))
|
||||||
return acc
|
return acc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,12 +124,13 @@ func TestRegenerateNotaryWallets(t *testing.T) {
|
||||||
acc4WIF = "L1ioz93TNt6Nu1aoMpZQ4zgdtgC8ZvJMC6pyHFkrovdR3SFwbn6n"
|
acc4WIF = "L1ioz93TNt6Nu1aoMpZQ4zgdtgC8ZvJMC6pyHFkrovdR3SFwbn6n"
|
||||||
)
|
)
|
||||||
|
|
||||||
acc1 := getAccount(t, acc1WIF, "one")
|
scryptParams := keys.ScryptParams{N: 2, R: 1, P: 1}
|
||||||
acc2 := getAccount(t, acc2WIF, "one")
|
acc1 := getAccountWithScrypt(t, acc1WIF, "one", scryptParams)
|
||||||
acc3 := getAccount(t, acc3WIF, "four")
|
acc2 := getAccountWithScrypt(t, acc2WIF, "one", scryptParams)
|
||||||
|
acc3 := getAccountWithScrypt(t, acc3WIF, "four", scryptParams)
|
||||||
createWallet(t, path.Join(walletDir, "notary1.json"), acc1, acc2, acc3)
|
createWallet(t, path.Join(walletDir, "notary1.json"), acc1, acc2, acc3)
|
||||||
|
|
||||||
acc4 := getAccount(t, acc4WIF, "two")
|
acc4 := getAccountWithScrypt(t, acc4WIF, "two", scryptParams)
|
||||||
createWallet(t, path.Join(walletDir, "notary2.json"), acc4)
|
createWallet(t, path.Join(walletDir, "notary2.json"), acc4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +174,7 @@ func TestRegenerateCLITestwallet(t *testing.T) {
|
||||||
accWIF = "L23LrQNWELytYLvb5c6dXBDdF2DNPL9RRNWPqppv3roxacSnn8CN"
|
accWIF = "L23LrQNWELytYLvb5c6dXBDdF2DNPL9RRNWPqppv3roxacSnn8CN"
|
||||||
)
|
)
|
||||||
|
|
||||||
acc := getAccount(t, accWIF, "testpass")
|
acc := getAccountWithScrypt(t, accWIF, "testpass", keys.ScryptParams{N: 2, R: 1, P: 1})
|
||||||
acc.Label = "kek"
|
acc.Label = "kek"
|
||||||
createWallet(t, walletPath, acc)
|
createWallet(t, walletPath, acc)
|
||||||
}
|
}
|
||||||
|
@ -184,9 +195,53 @@ func TestRegenerateCLITestwallet_NEO3(t *testing.T) {
|
||||||
func createWallet(t *testing.T, path string, accs ...*Account) {
|
func createWallet(t *testing.T, path string, accs ...*Account) {
|
||||||
w, err := NewWallet(path)
|
w, err := NewWallet(path)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
if len(accs) == 0 {
|
||||||
|
t.Fatal("provide at least 1 account")
|
||||||
|
}
|
||||||
for _, acc := range accs {
|
for _, acc := range accs {
|
||||||
w.AddAccount(acc)
|
w.AddAccount(acc)
|
||||||
}
|
}
|
||||||
require.NoError(t, w.savePretty())
|
require.NoError(t, w.savePretty())
|
||||||
w.Close()
|
w.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRegenerateCLIWallet1_solo(t *testing.T) {
|
||||||
|
if !regenerate {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const (
|
||||||
|
walletPath = "../../cli/testdata/wallet1_solo.json"
|
||||||
|
verifyWIF = "L3W8gi36Y3KPqyR54VJaE1agH9yPvW2hALNZy1BerDwWce9P9xEy"
|
||||||
|
verifyNEFPath = "../../cli/testdata/verify.nef"
|
||||||
|
verifyManifestPath = "../../cli/testdata/verify.manifest.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
scrypt := keys.ScryptParams{N: 2, R: 1, P: 1}
|
||||||
|
wif := privnetWIFs[0]
|
||||||
|
acc1 := getAccountWithScrypt(t, wif, "one", scrypt)
|
||||||
|
acc1.Default = true
|
||||||
|
acc2 := getAccountWithScrypt(t, wif, "one", scrypt)
|
||||||
|
require.NoError(t, acc2.ConvertMultisig(3, getKeys(t)))
|
||||||
|
|
||||||
|
acc3 := getAccountWithScrypt(t, wif, "one", scrypt)
|
||||||
|
require.NoError(t, acc3.ConvertMultisig(1, keys.PublicKeys{getKeys(t)[0]}))
|
||||||
|
|
||||||
|
acc4 := getAccountWithScrypt(t, verifyWIF, "pass", scrypt) // deployed verify.go contract
|
||||||
|
f, err := ioutil.ReadFile(verifyNEFPath)
|
||||||
|
require.NoError(t, err)
|
||||||
|
nefFile, err := nef.FileFromBytes(f)
|
||||||
|
require.NoError(t, err)
|
||||||
|
manifestBytes, err := ioutil.ReadFile(verifyManifestPath)
|
||||||
|
require.NoError(t, err)
|
||||||
|
m := &manifest.Manifest{}
|
||||||
|
require.NoError(t, json.Unmarshal(manifestBytes, m))
|
||||||
|
hash := state.CreateContractHash(acc3.PrivateKey().GetScriptHash(), nefFile.Checksum, m.Name)
|
||||||
|
acc4.Address = address.Uint160ToString(hash)
|
||||||
|
acc4.Contract = &Contract{
|
||||||
|
Script: nefFile.Script,
|
||||||
|
Deployed: true,
|
||||||
|
Parameters: []ContractParam{},
|
||||||
|
}
|
||||||
|
acc4.Label = "verify"
|
||||||
|
createWallet(t, walletPath, acc1, acc2, acc3, acc4)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue