mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +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": [
|
||||
{
|
||||
"address": "Nfyz4KcsgYepRJw1W5C2uKCi6QWKf7v6gG",
|
||||
"key": "6PYVjvHy8n4suq81uxkWqriiffKWFpTFPve57HdzWdDhpYUUYRUTai1jZS",
|
||||
"key": "6PYVjvHyAFQPXCU3PNsiRbF1RxEyyrT4PqLbSEEZcyYDFAMpSxPZnuRznY",
|
||||
"label": "kek",
|
||||
"contract": {
|
||||
"script": "DCECl3UyEIq6T5RRIXS6z4tNdZPTzQ7NvXyx7FwK05d9UyZBVuezJw==",
|
||||
|
@ -20,9 +20,9 @@
|
|||
}
|
||||
],
|
||||
"scrypt": {
|
||||
"n": 16384,
|
||||
"r": 8,
|
||||
"p": 8
|
||||
"n": 2,
|
||||
"r": 1,
|
||||
"p": 1
|
||||
},
|
||||
"extra": {
|
||||
"Tokens": null
|
||||
|
|
130
cli/testdata/wallet1_solo.json
vendored
130
cli/testdata/wallet1_solo.json
vendored
|
@ -1,84 +1,84 @@
|
|||
{
|
||||
"extra" : {
|
||||
"Tokens" : null
|
||||
},
|
||||
"accounts" : [
|
||||
"version": "3.0",
|
||||
"accounts": [
|
||||
{
|
||||
"label" : "",
|
||||
"key" : "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY",
|
||||
"lock" : false,
|
||||
"isDefault" : true,
|
||||
"contract" : {
|
||||
"script" : "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBVuezJw==",
|
||||
"deployed" : false,
|
||||
"parameters" : [
|
||||
"address": "Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn",
|
||||
"key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBVuezJw==",
|
||||
"parameters": [
|
||||
{
|
||||
"name" : "parameter0",
|
||||
"type" : "Signature"
|
||||
}
|
||||
]
|
||||
},
|
||||
"address" : "Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn"
|
||||
},
|
||||
{
|
||||
"lock" : false,
|
||||
"isDefault" : false,
|
||||
"contract" : {
|
||||
"script" : "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6",
|
||||
"parameters" : [
|
||||
{
|
||||
"name" : "parameter0",
|
||||
"type" : "Signature"
|
||||
},
|
||||
{
|
||||
"name" : "parameter1",
|
||||
"type" : "Signature"
|
||||
},
|
||||
{
|
||||
"type" : "Signature",
|
||||
"name" : "parameter2"
|
||||
"name": "parameter0",
|
||||
"type": "Signature"
|
||||
}
|
||||
],
|
||||
"deployed" : false
|
||||
"deployed": false
|
||||
},
|
||||
"address" : "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq",
|
||||
"label" : "",
|
||||
"key" : "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY"
|
||||
"lock": false,
|
||||
"isDefault": true
|
||||
},
|
||||
{
|
||||
"lock" : false,
|
||||
"isDefault" : false,
|
||||
"contract" : {
|
||||
"parameters" : [
|
||||
"address": "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq",
|
||||
"key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6",
|
||||
"parameters": [
|
||||
{
|
||||
"name" : "parameter0",
|
||||
"type" : "Signature"
|
||||
"name": "parameter0",
|
||||
"type": "Signature"
|
||||
},
|
||||
{
|
||||
"name": "parameter1",
|
||||
"type": "Signature"
|
||||
},
|
||||
{
|
||||
"name": "parameter2",
|
||||
"type": "Signature"
|
||||
}
|
||||
],
|
||||
"deployed" : false,
|
||||
"script" : "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEUGe0Nw6"
|
||||
"deployed": false
|
||||
},
|
||||
"address" : "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP",
|
||||
"label" : "",
|
||||
"key" : "6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY"
|
||||
"lock": false,
|
||||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address" : "NU4CTk9H2fgNCuC3ZPqX4LjUX3MHt3Rh6p",
|
||||
"contract" : {
|
||||
"script" : "EdsgQFcAA0BXAQR4eXp7VBTAcAwOT25ORVAxMVBheW1lbnRoUEGVAW9hIUA=",
|
||||
"parameters" : [],
|
||||
"deployed" : true
|
||||
"address": "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP",
|
||||
"key": "6PYM8VdX3hY4B51UJxmm8D41RQMbpJT8aYHibyQ67gjkUPmvQgu51Y5UQR",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEUGe0Nw6",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
"type": "Signature"
|
||||
}
|
||||
],
|
||||
"deployed": false
|
||||
},
|
||||
"lock" : false,
|
||||
"isDefault" : false,
|
||||
"key" : "6PYSATFzuRXXUeq7tMDyA1AGxWdVcm7ftbkqtGBt69WJBapT1tkwjp1zpx",
|
||||
"label" : "acc"
|
||||
"lock": false,
|
||||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "NU4CTk9H2fgNCuC3ZPqX4LjUX3MHt3Rh6p",
|
||||
"key": "6PYSATFztBa3CHjSR6sLAKungUEAbQUCVE16KzmaQQ38gLeYGZ9Knd5mGv",
|
||||
"label": "verify",
|
||||
"contract": {
|
||||
"script": "EdsgQFcAA0BXAQR4eXp7VBTAcAwOT25ORVAxMVBheW1lbnRoUEGVAW9hIUA=",
|
||||
"parameters": [],
|
||||
"deployed": true
|
||||
},
|
||||
"lock": false,
|
||||
"isDefault": false
|
||||
}
|
||||
],
|
||||
"version" : "3.0",
|
||||
"scrypt" : {
|
||||
"r" : 8,
|
||||
"n" : 16384,
|
||||
"p" : 8
|
||||
"scrypt": {
|
||||
"n": 2,
|
||||
"r": 1,
|
||||
"p": 1
|
||||
},
|
||||
"extra": {
|
||||
"Tokens": null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ func TestWalletExport(t *testing.T) {
|
|||
"--wallet", validatorWallet, validatorAddr)
|
||||
line, err := e.Out.ReadString('\n')
|
||||
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.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": [
|
||||
{
|
||||
"address": "Nbruchf1SGfar3sN4cPr1UG1bWqADrN5sh",
|
||||
"key": "6PYRC8sNNB5rVx96ezh6Eefw8JcdQPRBfHx7hfe251m4bwHQnH2cZbcRk8",
|
||||
"key": "6PYRC8sNMsyDRf8wVvQEpBJa5JXKbQ1SXGaXTvzW8u8mcpBTYs6E6kk1a6",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "DCEDm5PmbOfVPmYXTSVW903XnOhhNBTsF9oDlVYusIH/ui1BVuezJw==",
|
||||
|
@ -20,7 +20,7 @@
|
|||
},
|
||||
{
|
||||
"address": "NiYvEoR2FTD8FmGXtg1WMhkaTS9A6VH7YV",
|
||||
"key": "6PYMecvacj5qTSB771Q9k4wfqTRK4SXSQhmDsDAxZxBgEVJf4BsnrgrQYS",
|
||||
"key": "6PYMecvacKctbTeqApPGuukViQ2bbvFG4qNNm7VJS4oGzTF3rpptsbDaKd",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "DCEDHRWEIGXHCwUU2Fc7B0qrYPezXR0sfdEduRExyzIKVC9BVuezJw==",
|
||||
|
@ -37,7 +37,7 @@
|
|||
},
|
||||
{
|
||||
"address": "NcPWfiU7bJkUpBruEQcGRyo91bTWijcUXY",
|
||||
"key": "6PYWH6sS2JVshBA5ijMAT1CtFbs9LcLuthYoR4eZMD8TyXShD1c2zLsfjC",
|
||||
"key": "6PYWH6sS3VzGWq6K8oSoiRKDKSKkHHWhjHn9zQ8Qs2Zn9KboqWzseieXj2",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "DCECmUfs/gqKHd3AdJm5+Ev6zkubV8pP8DZzgu8+t5WdphJBVuezJw==",
|
||||
|
@ -54,9 +54,9 @@
|
|||
}
|
||||
],
|
||||
"scrypt": {
|
||||
"n": 16384,
|
||||
"r": 8,
|
||||
"p": 8
|
||||
"n": 2,
|
||||
"r": 1,
|
||||
"p": 1
|
||||
},
|
||||
"extra": {
|
||||
"Tokens": null
|
||||
|
|
8
pkg/services/notary/testdata/notary2.json
vendored
8
pkg/services/notary/testdata/notary2.json
vendored
|
@ -3,7 +3,7 @@
|
|||
"accounts": [
|
||||
{
|
||||
"address": "NaVp3ZxwZWA84DRewRjnBLFstaeBuVMKwR",
|
||||
"key": "6PYK1JEBNRL1jnqpD2Vct9sa5gjSfU5p42zavZBmWmKWR8oKvS5mPzcvqm",
|
||||
"key": "6PYK1JEBNB9ndo7HmC9mXeNbdPi9NGb81C2tJrsTw4PBkcT64X6SQhnxHq",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "DCECIcKj0GFdv4b1NZrw9X6zLNLWzmNKAxtw6olIMZxpPRRBVuezJw==",
|
||||
|
@ -20,9 +20,9 @@
|
|||
}
|
||||
],
|
||||
"scrypt": {
|
||||
"n": 16384,
|
||||
"r": 8,
|
||||
"p": 8
|
||||
"n": 2,
|
||||
"r": 1,
|
||||
"p": 1
|
||||
},
|
||||
"extra": {
|
||||
"Tokens": null
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package wallet
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"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/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"
|
||||
)
|
||||
|
||||
|
@ -37,9 +43,13 @@ func getKeys(t *testing.T) []*keys.PublicKey {
|
|||
}
|
||||
|
||||
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)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, acc.Encrypt(pass, keys.NEP2ScryptParams()))
|
||||
require.NoError(t, acc.Encrypt(pass, scrypt))
|
||||
return acc
|
||||
}
|
||||
|
||||
|
@ -114,12 +124,13 @@ func TestRegenerateNotaryWallets(t *testing.T) {
|
|||
acc4WIF = "L1ioz93TNt6Nu1aoMpZQ4zgdtgC8ZvJMC6pyHFkrovdR3SFwbn6n"
|
||||
)
|
||||
|
||||
acc1 := getAccount(t, acc1WIF, "one")
|
||||
acc2 := getAccount(t, acc2WIF, "one")
|
||||
acc3 := getAccount(t, acc3WIF, "four")
|
||||
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, 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)
|
||||
}
|
||||
|
||||
|
@ -163,7 +174,7 @@ func TestRegenerateCLITestwallet(t *testing.T) {
|
|||
accWIF = "L23LrQNWELytYLvb5c6dXBDdF2DNPL9RRNWPqppv3roxacSnn8CN"
|
||||
)
|
||||
|
||||
acc := getAccount(t, accWIF, "testpass")
|
||||
acc := getAccountWithScrypt(t, accWIF, "testpass", keys.ScryptParams{N: 2, R: 1, P: 1})
|
||||
acc.Label = "kek"
|
||||
createWallet(t, walletPath, acc)
|
||||
}
|
||||
|
@ -184,9 +195,53 @@ func TestRegenerateCLITestwallet_NEO3(t *testing.T) {
|
|||
func createWallet(t *testing.T, path string, accs ...*Account) {
|
||||
w, err := NewWallet(path)
|
||||
require.NoError(t, err)
|
||||
if len(accs) == 0 {
|
||||
t.Fatal("provide at least 1 account")
|
||||
}
|
||||
for _, acc := range accs {
|
||||
w.AddAccount(acc)
|
||||
}
|
||||
require.NoError(t, w.savePretty())
|
||||
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