Skip to content

Commit

Permalink
test: use new regtest params.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Sep 27, 2019
1 parent fb266ef commit af60704
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 26 deletions.
46 changes: 23 additions & 23 deletions test/data/export.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"watchOnly": true,
"accountDepth": 1,
"tokenDepth": 0,
"token": "1111111111111111111111111111111111111111111111111111111111111111",
"master": "003e04334be01bfa16e233a073d39172060f41f9c60ff4c9cd76b84a80aa74c8847bdb11e514aae4ac284a9b4f8544dfa61a2bcac17f536383122796ec464a438f018000028a85e0467678fc2499e375a76ecbc3dc",
"joinPubKey": "0308c749ece3230fca2a324623963c6ec20c4be9056b0d0089ecb95f1bfbb29396",
"timestamp": 1564595915,
"token": "0000000000000000000000000000000000000000000000000000000000000000",
"master": "00b9507e1626c181466d1deaf30822f58b7adabf88913a2af6c50bf9d550270dc93c43e7fb9d64a194c97d6587b5e5489dd7b9690235e8c3c204ce0cf6fafceb7201800002a7caef930dda0c96ced472d6cbb73683",
"joinPubKey": "02156440ee2d931f92c63ec925b2cdaeff430c9a668f20c004a901d668860b301e",
"timestamp": 1569598356,
"accounts": [
{
"name": "default",
"witness": true,
"witness": false,
"initialized": true,
"watchOnly": true,
"type": "multisig",
Expand All @@ -19,42 +19,42 @@
"accountIndex": 0,
"receiveDepth": 1,
"changeDepth": 1,
"nestedDepth": 1,
"lookahead": 11,
"accountKey": "rpubKBBV6Y2asgWUBVPmPfaBdufC4RxMoB2HYBxi1bN9bW9Pyodf5TWAJeog7NBsradD5MHe9M7RWkK6p5ZGir6iVHUiQdVSVrKVSU19xYmVQMLV",
"nestedDepth": 0,
"lookahead": 10,
"accountKey": "tpubDCL1g1wQcQy75xoGZM7nmCpC9Lc3ud8tisuaSC6SUXP9h3ZmHKDL1teTTZwvpGgs73GV8gcixuL72BSDDUbdpVSR8Q4EMs6ar7ejQZrtZAS",
"keys": [
"rpubKBBvERPndYY5wx6ibRr7JpsABertsCGLPDkk55TvMpKqtJku89WngaNickRxy6hrRmmzVmByFg1ocKiHmNas4m6RpeTmH7Uzwh9HdKC5fxqW"
"tpubDCxTqkVJkY3R6vGQfBrGRFdijcskVMET8rfdXeiLf5jscN4ncyu7EZHgoP84UASpuUED7Cj1u6qt4cKKYbRNU3apCt5VUfN2KJkxUn9NW6w"
]
}
],
"cosigners": [
{
"id": 0,
"name": "cosigner1",
"data": "63636363636363636363",
"data": "",
"purpose": 44,
"fingerPrint": 891844849,
"accountKey": "rpubKBBV6Y2asgWUBVPmPfaBdufC4RxMoB2HYBxi1bN9bW9Pyodf5TWAJeog7NBsradD5MHe9M7RWkK6p5ZGir6iVHUiQdVSVrKVSU19xYmVQMLV",
"authPubKey": "02bad879395e171121982a397d0a8fafb3063eea61d6984824798c08bc85add085",
"joinSignature": "2043d1dfd38115082cd78a7de23d6a2e9a5ccc437022ebc07c8e81e57d8f1797be292683aeea5d43c3f25ff0976718ae0b080f4e132f7084630c4b5b7a3d74a99a",
"token": "0101010101010101010101010101010101010101010101010101010101010101",
"fingerPrint": 1539137430,
"accountKey": "tpubDCL1g1wQcQy75xoGZM7nmCpC9Lc3ud8tisuaSC6SUXP9h3ZmHKDL1teTTZwvpGgs73GV8gcixuL72BSDDUbdpVSR8Q4EMs6ar7ejQZrtZAS",
"authPubKey": "031c251f2b6454023da9774a00493b634e8244a167ee3414cbb7dfe35e9d71a224",
"joinSignature": "1f2317cbc4af2e37ec939ef81fdd68a8a530d26c130180a28adba166c41e27d4561276e81fe5b0bf3b82c10deeba4e73c5f5b280d43dbc5e5553506fe7b8a79d87",
"token": "0000000000000000000000000000000000000000000000000000000000000000",
"tokenDepth": 0
},
{
"id": 1,
"name": "cosigner2",
"data": "",
"purpose": 44,
"fingerPrint": 2264922574,
"accountKey": "rpubKBBvERPndYY5wx6ibRr7JpsABertsCGLPDkk55TvMpKqtJku89WngaNickRxy6hrRmmzVmByFg1ocKiHmNas4m6RpeTmH7Uzwh9HdKC5fxqW",
"authPubKey": "0203c12bbb10cd45afde168b548765106f8255e43142d1250a1551496d31e23b17",
"joinSignature": "2020342880c3db62e49b6450ce1f55f7334ce5185d6e49e3ae9c2ebe078c82b7f0365e4097fc68ec413606cf3158005daa935941b4a3f36bffee25936b2e25aa15",
"token": "0202020202020202020202020202020202020202020202020202020202020202",
"fingerPrint": 1451414035,
"accountKey": "tpubDCxTqkVJkY3R6vGQfBrGRFdijcskVMET8rfdXeiLf5jscN4ncyu7EZHgoP84UASpuUED7Cj1u6qt4cKKYbRNU3apCt5VUfN2KJkxUn9NW6w",
"authPubKey": "039708c3b820eafef0fed7d4a8e298821bb2ef3fb2dde811a4a2617ec91e1616be",
"joinSignature": "1fd296933eb6a9d752b0790c4fe1c309f2fc9cfcce75327537b45409227a17c2703a9ec71d5fbf7d810c53cacf5e2a37b09c1a49c42aac35d0e733cfb536fc49ca",
"token": "0000000000000000000000000000000000000000000000000000000000000000",
"tokenDepth": 0
}
]
},
"rawCosigner0": "0000000000010101010101010101010101010101010101010101010101010101010101010109636f7369676e6572310000002c352878f10a63636363636363636363eab4fa0503bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90eab695202bad879395e171121982a397d0a8fafb3063eea61d6984824798c08bc85add0852043d1dfd38115082cd78a7de23d6a2e9a5ccc437022ebc07c8e81e57d8f1797be292683aeea5d43c3f25ff0976718ae0b080f4e132f7084630c4b5b7a3d74a99a",
"rawAccount": "030102020100000001000000010000000b03bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90103fa60625880000000fef7d794e8cffe9f3f5a3c0857a7cab9eda6dbfcd53de7110d032ceed55ca3f40396a436242abcb53908c320c7483db796901524fa1a19b4ab15d012ba2f0c1591000000000764656661756c74",
"rawWallet": "0101000000111111111111111111111111111111111111111111111111111111111111111100000000003e04334be01bfa16e233a073d39172060f41f9c60ff4c9cd76b84a80aa74c8847bdb11e514aae4ac284a9b4f8544dfa61a2bcac17f536383122796ec464a438f018000028a85e0467678fc2499e375a76ecbc3dccbd6415d000308c749ece3230fca2a324623963c6ec20c4be9056b0d0089ecb95f1bfbb2939601000000030102020100000001000000010000000b03bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90103fa60625880000000fef7d794e8cffe9f3f5a3c0857a7cab9eda6dbfcd53de7110d032ceed55ca3f40396a436242abcb53908c320c7483db796901524fa1a19b4ab15d012ba2f0c1591000000000764656661756c74020000000000010101010101010101010101010101010101010101010101010101010101010109636f7369676e6572310000002c352878f10a63636363636363636363eab4fa0503bf6a357980000000584c9b230fe4fb6da9b42bc2c1fea39b526dc374ed8971fc6b7d3a720c7124ea0220d745a18cc3da8ca28a4f06ef6975e186b5531138379fb01c9e2532f3e8dce90eab695202bad879395e171121982a397d0a8fafb3063eea61d6984824798c08bc85add0852043d1dfd38115082cd78a7de23d6a2e9a5ccc437022ebc07c8e81e57d8f1797be292683aeea5d43c3f25ff0976718ae0b080f4e132f7084630c4b5b7a3d74a99a0100000000020202020202020202020202020202020202020202020202020202020202020209636f7369676e6572320000002c86fff9ce00eab4fa0503fa60625880000000fef7d794e8cffe9f3f5a3c0857a7cab9eda6dbfcd53de7110d032ceed55ca3f40396a436242abcb53908c320c7483db796901524fa1a19b4ab15d012ba2f0c1591b4868c490203c12bbb10cd45afde168b548765106f8255e43142d1250a1551496d31e23b172020342880c3db62e49b6450ce1f55f7334ce5185d6e49e3ae9c2ebe078c82b7f0365e4097fc68ec413606cf3158005daa935941b4a3f36bffee25936b2e25aa15"
"rawCosigner0": "0000000000000000000000000000000000000000000000000000000000000000000000000009636f7369676e6572310000002c5bbd5f9600043587cf03295126ec8000000039225eb77c98453f458e3e8ea2e8726d081129e901a479aa3077fc3f2098d8cb0254ab34d108bb047dd7182506362dd7a8893e4c128bbab882b5a1bf39d021c3fcb854766b031c251f2b6454023da9774a00493b634e8244a167ee3414cbb7dfe35e9d71a2241f2317cbc4af2e37ec939ef81fdd68a8a530d26c130180a28adba166c41e27d4561276e81fe5b0bf3b82c10deeba4e73c5f5b280d43dbc5e5553506fe7b8a79d87",
"rawAccount": "010102020100000001000000000000000a03295126ec8000000039225eb77c98453f458e3e8ea2e8726d081129e901a479aa3077fc3f2098d8cb0254ab34d108bb047dd7182506362dd7a8893e4c128bbab882b5a1bf39d021c3fc01037ed2202880000000441bc5407a8c916f99e2ec494e0d394c375e8e696257f8528caef6a97e659f2d0243fd358b8907b6fef21ddfc2462d72bdadc7931278b5f903e1ec7ea2335264c4000000000764656661756c74",
"rawWallet": "010100000000000000000000000000000000000000000000000000000000000000000000000000000000b9507e1626c181466d1deaf30822f58b7adabf88913a2af6c50bf9d550270dc93c43e7fb9d64a194c97d6587b5e5489dd7b9690235e8c3c204ce0cf6fafceb7201800002a7caef930dda0c96ced472d6cbb73683942b8e5d0002156440ee2d931f92c63ec925b2cdaeff430c9a668f20c004a901d668860b301e01000000010102020100000001000000000000000a03295126ec8000000039225eb77c98453f458e3e8ea2e8726d081129e901a479aa3077fc3f2098d8cb0254ab34d108bb047dd7182506362dd7a8893e4c128bbab882b5a1bf39d021c3fc01037ed2202880000000441bc5407a8c916f99e2ec494e0d394c375e8e696257f8528caef6a97e659f2d0243fd358b8907b6fef21ddfc2462d72bdadc7931278b5f903e1ec7ea2335264c4000000000764656661756c74020000000000000000000000000000000000000000000000000000000000000000000000000009636f7369676e6572310000002c5bbd5f9600043587cf03295126ec8000000039225eb77c98453f458e3e8ea2e8726d081129e901a479aa3077fc3f2098d8cb0254ab34d108bb047dd7182506362dd7a8893e4c128bbab882b5a1bf39d021c3fcb854766b031c251f2b6454023da9774a00493b634e8244a167ee3414cbb7dfe35e9d71a2241f2317cbc4af2e37ec939ef81fdd68a8a530d26c130180a28adba166c41e27d4561276e81fe5b0bf3b82c10deeba4e73c5f5b280d43dbc5e5553506fe7b8a79d870100000000000000000000000000000000000000000000000000000000000000000000000009636f7369676e6572320000002c5682d21300043587cf037ed2202880000000441bc5407a8c916f99e2ec494e0d394c375e8e696257f8528caef6a97e659f2d0243fd358b8907b6fef21ddfc2462d72bdadc7931278b5f903e1ec7ea2335264c41ee52894039708c3b820eafef0fed7d4a8e298821bb2ef3fb2dde811a4a2617ec91e1616be1fd296933eb6a9d752b0790c4fe1c309f2fc9cfcce75327537b45409227a17c2703a9ec71d5fbf7d810c53cacf5e2a37b09c1a49c42aac35d0e733cfb536fc49ca"
}
39 changes: 36 additions & 3 deletions test/wallet-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ const WalletNodeClient = require('../lib/walletclient');
const MultisigWallet = require('../lib/wallet');
const CosignerCtx = require('./util/cosigner-context');

const NETWORK_NAME = 'regtest';
const network = Network.get(NETWORK_NAME);

// at this point we don't use anything from MSDB
const TEST_MSDB = {
db: {},
logger: Logger.global,
network: Network.primary
network: network
};

const WALLET_OPTIONS = {
Expand All @@ -31,13 +34,16 @@ describe('MultisigWallet', function () {
let wdb, msdb;

beforeEach(async () => {
wdb = new WalletDB();
wdb = new WalletDB({
network: network
});

const wdbClient = new WalletNodeClient({
wdb
});

msdb = new MultisigDB({
network: network,
client: wdbClient
});

Expand All @@ -52,11 +58,13 @@ describe('MultisigWallet', function () {

it('should create wallet from options', () => {
const cosignerCtx1 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
token: Buffer.alloc(32, 1)
});

const cosignerCtx2 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
token: Buffer.alloc(32, 2),
joinPrivKey: cosignerCtx1.joinPrivKey
Expand Down Expand Up @@ -99,11 +107,13 @@ describe('MultisigWallet', function () {

it('should reserialize correctly', () => {
const cosignerCtx1 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
token: Buffer.alloc(32, 1)
});

const cosignerCtx2 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
token: Buffer.alloc(32, 2),
joinPrivKey: cosignerCtx1.joinPrivKey
Expand Down Expand Up @@ -137,6 +147,7 @@ describe('MultisigWallet', function () {

it('should create multisig wallet', async () => {
const cosignerCtx = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
token: Buffer.alloc(32, 3)
});
Expand All @@ -157,11 +168,12 @@ describe('MultisigWallet', function () {

assert.strictEqual(mswallet.m, account.m);
assert.strictEqual(mswallet.n, account.n);
assert.strictEqual(account.accountKey.xpubkey(), cosignerCtx.xpub);
assert.strictEqual(account.accountKey.xpubkey(network), cosignerCtx.xpub);
});

it('should fail creating existing wallet', async () => {
const cosignerCtx = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner1',
token: Buffer.alloc(32, 4)
Expand All @@ -179,6 +191,7 @@ describe('MultisigWallet', function () {

try {
const cosignerCtx2 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner2',
master: cosignerCtx.master,
Expand All @@ -203,6 +216,7 @@ describe('MultisigWallet', function () {

try {
const cosignerCtx3 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner2',
master: cosignerCtx.master,
Expand All @@ -227,6 +241,7 @@ describe('MultisigWallet', function () {

it('should get multisig wallet', async () => {
const cosignerCtx = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner1'
});
Expand Down Expand Up @@ -273,6 +288,7 @@ describe('MultisigWallet', function () {
}

const cosignerCtx = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner',
token: Buffer.alloc(32, 6)
Expand Down Expand Up @@ -311,6 +327,7 @@ describe('MultisigWallet', function () {

it('should remove multisig wallet', async () => {
const cosignerCtx = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner1',
token: Buffer.alloc(32, 7)
Expand Down Expand Up @@ -343,15 +360,18 @@ describe('MultisigWallet', function () {
it('should join wallet with joinKey', async () => {
const walletName = 'wallet-1of3';
const cosignerCtx1 = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner1'
});
const cosignerCtx2 = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner2',
joinPrivKey: cosignerCtx1.joinPrivKey
});
const cosignerCtx3 = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner3',
joinPrivKey: cosignerCtx1.joinPrivKey
Expand Down Expand Up @@ -411,10 +431,12 @@ describe('MultisigWallet', function () {
it('should fail joining with duplicate XPUB', async () => {
const walletName = 'wallet-1of3';
const cosignerCtx1 = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner1'
});
const cosignerCtx2 = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner2',
joinPrivKey: cosignerCtx1.joinPrivKey
Expand All @@ -436,6 +458,7 @@ describe('MultisigWallet', function () {
let err;
try {
const cosignerCtx = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner3',
master: cosignerCtx1.master,
Expand All @@ -456,6 +479,7 @@ describe('MultisigWallet', function () {

try {
const cosignerCtx = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner3',
master: cosignerCtx2.master,
Expand All @@ -476,15 +500,18 @@ describe('MultisigWallet', function () {
const walletName = 'wallet-1of2';

const cosignerCtx1 = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner1'
});
const cosignerCtx2 = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner2',
joinPrivKey: cosignerCtx1.joinPrivKey
});
const cosignerCtx3 = new CosignerCtx({
network: network,
walletName: walletName,
name: 'cosigner3',
joinPrivKey: cosignerCtx1.joinPrivKey
Expand Down Expand Up @@ -522,12 +549,14 @@ describe('MultisigWallet', function () {

it('should authenticate user with cosignerToken', async () => {
const cosignerCtx1 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner1',
token: Buffer.alloc(32, 1)
});

const cosignerCtx2 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner2',
token: Buffer.alloc(32, 2),
Expand Down Expand Up @@ -573,6 +602,7 @@ describe('MultisigWallet', function () {
const token2 = Buffer.alloc(32, 2);

const cosignerCtx = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner1',
token: token1
Expand Down Expand Up @@ -607,11 +637,13 @@ describe('MultisigWallet', function () {
// have default wallet for each test.
beforeEach(async () => {
const cosignerCtx1 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner1'
});

const cosignerCtx2 = new CosignerCtx({
network: network,
walletName: WALLET_OPTIONS.id,
name: 'cosigner2',
joinPrivKey: cosignerCtx1.joinPrivKey
Expand All @@ -633,6 +665,7 @@ describe('MultisigWallet', function () {
it('should fail exporting uninitialized wallet', async () => {
const wid = 'export-uninitialized';
const cosignerCtx = new CosignerCtx({
network: network,
walletName: wid,
name: 'cosigner'
});
Expand Down

0 comments on commit af60704

Please sign in to comment.