From 27ba3dfc35d46379e6a67c0082d9a2b2b864c922 Mon Sep 17 00:00:00 2001 From: Nodari Chkuaselidze Date: Fri, 17 Jun 2022 15:41:17 +0400 Subject: [PATCH 1/2] pkg: update urkel and package.json --- package-lock.json | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 03d7f1be..7efd17c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hsd", - "version": "3.0.1", + "version": "4.99.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "hsd", - "version": "3.0.1", + "version": "4.99.0", "license": "MIT", "dependencies": { "bcfg": "~0.1.7", @@ -35,7 +35,7 @@ "goosig": "~0.10.0", "hs-client": "~0.0.11", "n64": "~0.2.10", - "urkel": "~1.0.1" + "urkel": "~1.0.2" }, "bin": { "hs-seeder": "bin/hs-seeder", @@ -461,9 +461,9 @@ } }, "node_modules/urkel": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/urkel/-/urkel-1.0.1.tgz", - "integrity": "sha512-/ul3w/hvvGzppHqdpDAcEFe8kS1hi6ty5h7oQalIlVLwPNUJ/tz/h7KtIyNRC0+u7ANryq2Aw96N8snq+VYEOg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/urkel/-/urkel-1.0.2.tgz", + "integrity": "sha512-Y5UXbgBr6pczrD08N0SYJkWjtdtTTpmZsOvuftdrEHLnTjuxwSNjKsXYLQkICTptvnHAJ2OjI6XdAxtYTyOHew==", "dependencies": { "bfile": "~0.2.1", "bmutex": "~0.1.6", @@ -748,9 +748,9 @@ } }, "urkel": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/urkel/-/urkel-1.0.1.tgz", - "integrity": "sha512-/ul3w/hvvGzppHqdpDAcEFe8kS1hi6ty5h7oQalIlVLwPNUJ/tz/h7KtIyNRC0+u7ANryq2Aw96N8snq+VYEOg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/urkel/-/urkel-1.0.2.tgz", + "integrity": "sha512-Y5UXbgBr6pczrD08N0SYJkWjtdtTTpmZsOvuftdrEHLnTjuxwSNjKsXYLQkICTptvnHAJ2OjI6XdAxtYTyOHew==", "requires": { "bfile": "~0.2.1", "bmutex": "~0.1.6", diff --git a/package.json b/package.json index 546e7fa8..3c9a77c9 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "goosig": "~0.10.0", "hs-client": "~0.0.11", "n64": "~0.2.10", - "urkel": "~1.0.1" + "urkel": "~1.0.2" }, "devDependencies": { "bmocha": "^2.1.5" From f283bf2e10ab3756de57671274a5fc1339182247 Mon Sep 17 00:00:00 2001 From: Nodari Chkuaselidze Date: Tue, 21 Jun 2022 18:14:01 +0400 Subject: [PATCH 2/2] test: use name length 10 for grindName to reduce risk of repeating names. This may not apply to all the tests, but boundary checks from tree compaction test would fail from time to time because the test generates a lot of names and it was using length of 4 for the names. This would allow collisions to happen and tests fail. --- test/anyone-can-renew-test.js | 2 +- test/auction-reorg-test.js | 5 +++-- test/auction-rpc-test.js | 4 +++- test/auction-test.js | 5 +++-- test/chain-checkpoints-test.js | 12 +++++++----- test/chain-tree-compaction-test.js | 6 ++++-- test/interactive-swap-test.js | 2 +- test/mempool-test.js | 2 +- test/wallet-accounts-auction-test.js | 2 +- test/wallet-auction-test.js | 2 +- test/wallet-importname-test.js | 11 ++++++----- test/wallet-rescan-test.js | 6 ++++-- test/wallet-rpc-test.js | 10 ++++++---- 13 files changed, 41 insertions(+), 28 deletions(-) diff --git a/test/anyone-can-renew-test.js b/test/anyone-can-renew-test.js index 76fa0149..b0573928 100644 --- a/test/anyone-can-renew-test.js +++ b/test/anyone-can-renew-test.js @@ -42,7 +42,7 @@ const {wdb} = node.require('walletdb'); let alice, aliceReceive; let bob, bobReceive; -const name = rules.grindName(5, 1, network); +const name = rules.grindName(10, 1, network); const nameHash = rules.hashName(name); let heightBeforeOpen, heightBeforeRegister, heightBeforeFinalize; let coin; diff --git a/test/auction-reorg-test.js b/test/auction-reorg-test.js index 98016b66..5969c1d6 100644 --- a/test/auction-reorg-test.js +++ b/test/auction-reorg-test.js @@ -15,8 +15,9 @@ const ownership = require('../lib/covenants/ownership'); const network = Network.get('regtest'); const {treeInterval} = network.names; -const NAME1 = rules.grindName(10, 20, network); -const NAME2 = rules.grindName(10, 20, network); +const GNAME_SIZE = 10; +const NAME1 = rules.grindName(GNAME_SIZE, 20, network); +const NAME2 = rules.grindName(GNAME_SIZE, 20, network); const workers = new WorkerPool({ // Must be disabled for `ownership.ignore`. diff --git a/test/auction-rpc-test.js b/test/auction-rpc-test.js index 8e9c117a..b111a339 100644 --- a/test/auction-rpc-test.js +++ b/test/auction-rpc-test.js @@ -136,11 +136,13 @@ class TestUtil { } } +const GNAME_SIZE = 10; + describe('Auction RPCs', function() { this.timeout(60000); const util = new TestUtil(); - const name = rules.grindName(2, 0, Network.get('regtest')); + const name = rules.grindName(GNAME_SIZE, 0, Network.get('regtest')); let winner, loser; const winnerBid = { bid: 5, diff --git a/test/auction-test.js b/test/auction-test.js index a94e3ded..a224d9ad 100644 --- a/test/auction-test.js +++ b/test/auction-test.js @@ -11,8 +11,9 @@ const rules = require('../lib/covenants/rules'); const ownership = require('../lib/covenants/ownership'); const network = Network.get('regtest'); -const NAME1 = rules.grindName(10, 20, network); -const NAME2 = rules.grindName(10, 20, network); +const GNAME_SIZE = 10; +const NAME1 = rules.grindName(GNAME_SIZE, 20, network); +const NAME2 = rules.grindName(GNAME_SIZE, 20, network); const workers = new WorkerPool({ // Must be disabled for `ownership.ignore`. diff --git a/test/chain-checkpoints-test.js b/test/chain-checkpoints-test.js index 19977396..124fa59b 100644 --- a/test/chain-checkpoints-test.js +++ b/test/chain-checkpoints-test.js @@ -43,6 +43,8 @@ const wallet = new MemWallet({ network }); +const GNAME_SIZE = 10; + wallet.getNameStatus = async (nameHash) => { assert(Buffer.isBuffer(nameHash)); const height = chainGenerator.height + 1; @@ -155,11 +157,11 @@ describe('Checkpoints', function() { it('should win names in auction', async () => { // Only one bid, 0-value name - const name1 = rules.grindName(5, chainGenerator.height - 5, network); + const name1 = rules.grindName(GNAME_SIZE, chainGenerator.height - 5, network); // Two bids, name will have a value - const name2 = rules.grindName(5, chainGenerator.height - 5, network); + const name2 = rules.grindName(GNAME_SIZE, chainGenerator.height - 5, network); // Two bids, but wallet will not REGISTER - const name3 = rules.grindName(5, chainGenerator.height - 5, network); + const name3 = rules.grindName(GNAME_SIZE, chainGenerator.height - 5, network); const open1 = await wallet.sendOpen(name1); const open2 = await wallet.sendOpen(name2); @@ -218,7 +220,7 @@ describe('Checkpoints', function() { }); it('should bid in multiple blocks', async () => { - const name = rules.grindName(5, chainGenerator.height - 5, network); + const name = rules.grindName(GNAME_SIZE, chainGenerator.height - 5, network); const open = await wallet.sendOpen(name); @@ -366,7 +368,7 @@ describe('Checkpoints', function() { let invalidBlockEntry; before(async () => { - name = rules.grindName(5, chainGenerator.height - 5, network); + name = rules.grindName(GNAME_SIZE, chainGenerator.height - 5, network); }); after(async () => { diff --git a/test/chain-tree-compaction-test.js b/test/chain-tree-compaction-test.js index a2e4f2bc..cac74c4a 100644 --- a/test/chain-tree-compaction-test.js +++ b/test/chain-tree-compaction-test.js @@ -24,6 +24,8 @@ const { revealPeriod } = network.names; +const GNAME_SIZE = 10; + describe('Tree Compacting', function() { const oldKeepBlocks = network.block.keepBlocks; const oldpruneAfterHeight = network.block.pruneAfterHeight; @@ -182,7 +184,7 @@ describe('Tree Compacting', function() { }); it('should win an auction and register', async () => { - name = rules.grindName(3, chain.height, network); + name = rules.grindName(GNAME_SIZE, chain.height, network); nameHash = rules.hashName(name); send(await wallet.sendOpen(name), mempool); await mineBlocks(treeInterval + 1, mempool); @@ -1004,7 +1006,7 @@ describe('Tree Compacting', function() { // This ensures that every single block results in a different // tree and treeRoot without any auctions. if (open) { - const name = rules.grindName(4, chain.height - 1, network); + const name = rules.grindName(GNAME_SIZE, chain.height - 1, network); const tx = await wallet.sendOpen(name); job.pushTX(tx.toTX()); job.refresh(); diff --git a/test/interactive-swap-test.js b/test/interactive-swap-test.js index 0fdbaf83..0e5adb8d 100644 --- a/test/interactive-swap-test.js +++ b/test/interactive-swap-test.js @@ -38,7 +38,7 @@ let alice, bob, aliceReceive, bobReceive; let aliceOriginalBalance, bobOriginalBalance, bobFee; // These are data that will be communicated between Alice and Bob -const name = rules.grindName(5, 1, network); +const name = rules.grindName(10, 1, network); const nameHash = rules.hashName(name); const price = 1234567; // 1.234567 HNS let blob; diff --git a/test/mempool-test.js b/test/mempool-test.js index f0d86817..41902211 100644 --- a/test/mempool-test.js +++ b/test/mempool-test.js @@ -848,7 +848,7 @@ describe('Mempool', function() { const addr = chaincoins.createReceive().getAddress(); open.addOutput(addr, 90000); - const name = rules.grindName(5, 0, mempool.network); + const name = rules.grindName(10, 0, mempool.network); const rawName = Buffer.from(name, 'ascii'); const nameHash = rules.hashName(rawName); open.outputs[0].covenant.type = types.OPEN; diff --git a/test/wallet-accounts-auction-test.js b/test/wallet-accounts-auction-test.js index bee72000..67e1996c 100644 --- a/test/wallet-accounts-auction-test.js +++ b/test/wallet-accounts-auction-test.js @@ -27,7 +27,7 @@ const wclient = new WalletClient({ const {wdb} = node.require('walletdb'); -const name = rules.grindName(5, 1, network); +const name = rules.grindName(10, 1, network); let wallet, alice, bob, aliceReceive, bobReceive; async function mineBlocks(n, addr) { diff --git a/test/wallet-auction-test.js b/test/wallet-auction-test.js index a0fe689e..2d09d262 100644 --- a/test/wallet-auction-test.js +++ b/test/wallet-auction-test.js @@ -12,7 +12,7 @@ const rules = require('../lib/covenants/rules'); const Address = require('../lib/primitives/address'); const network = Network.get('regtest'); -const NAME1 = rules.grindName(5, 2, network); +const NAME1 = rules.grindName(10, 2, network); const { treeInterval, biddingPeriod, diff --git a/test/wallet-importname-test.js b/test/wallet-importname-test.js index 0322f9e9..0ace713e 100644 --- a/test/wallet-importname-test.js +++ b/test/wallet-importname-test.js @@ -30,9 +30,10 @@ const wclient = new WalletClient({ const {wdb} = node.require('walletdb'); -const name = rules.grindName(5, 1, network); +const GNAME_SIZE = 10; +const name = rules.grindName(GNAME_SIZE, 1, network); const nameHash = rules.hashName(name); -const wrongName = rules.grindName(5, 1, network); +const wrongName = rules.grindName(GNAME_SIZE, 1, network); const wrongNameHash = rules.hashName(wrongName); let alice, bob, aliceReceive, bobReceive; @@ -232,9 +233,9 @@ describe('Wallet Import Name', function() { }); describe('import multiple / overlapping names', function() { - const name1 = rules.grindName(4, 1, network); - const name2 = rules.grindName(5, 1, network); - const name3 = rules.grindName(6, 1, network); + const name1 = rules.grindName(GNAME_SIZE, 1, network); + const name2 = rules.grindName(GNAME_SIZE, 1, network); + const name3 = rules.grindName(GNAME_SIZE, 1, network); let startHeight; it('should open and bid from Alice\'s wallet', async () => { diff --git a/test/wallet-rescan-test.js b/test/wallet-rescan-test.js index 283116ff..e6eef13c 100644 --- a/test/wallet-rescan-test.js +++ b/test/wallet-rescan-test.js @@ -18,6 +18,8 @@ const { transferLockup } = network.names; +const GNAME_SIZE = 10; + describe('Wallet rescan with namestate transitions', function() { describe('Only sends OPEN', function() { // Bob runs a full node with wallet plugin @@ -49,7 +51,7 @@ describe('Wallet rescan with namestate transitions', function() { return node.chain.db.getNameStatus(nameHash, height, hardened); }; - const NAME = rules.grindName(4, 4, network); + const NAME = rules.grindName(GNAME_SIZE, 4, network); // Hash of the FINALIZE transaction let aliceFinalizeHash; @@ -303,7 +305,7 @@ describe('Wallet rescan with namestate transitions', function() { return node.chain.db.getNameStatus(nameHash, height, hardened); }; - const NAME = rules.grindName(4, 4, network); + const NAME = rules.grindName(GNAME_SIZE, 4, network); // Block that confirmed the bids let bidBlockHash; diff --git a/test/wallet-rpc-test.js b/test/wallet-rpc-test.js index 6053bd47..660c30b1 100644 --- a/test/wallet-rpc-test.js +++ b/test/wallet-rpc-test.js @@ -58,6 +58,8 @@ const wclient = new WalletClient({ const {wdb} = node.require('walletdb'); +const GNAME_SIZE = 10; + describe('Wallet RPC Methods', function() { this.timeout(15000); @@ -364,8 +366,8 @@ describe('Wallet RPC Methods', function() { }); describe('signmessagewithname & verifymessagewithname', () => { - const name = rules.grindName(5, 1, network); - const nonWalletName = rules.grindName(5, 1, network); + const name = rules.grindName(GNAME_SIZE, 1, network); + const nonWalletName = rules.grindName(GNAME_SIZE, 1, network); const message = 'Decentralized naming and certificate authority'; const invalidNames = ['', null, '\'null\'', 'localhost']; @@ -596,8 +598,8 @@ describe('Wallet RPC Methods', function() { }); it('should do an auction', async () => { - const NAME1 = rules.grindName(5, 2, network); - const NAME2 = rules.grindName(6, 3, network); + const NAME1 = rules.grindName(GNAME_SIZE, 2, network); + const NAME2 = rules.grindName(GNAME_SIZE, 3, network); const addr = await wclient.execute('getnewaddress', []); await nclient.execute('generatetoaddress', [10, addr]); await forValue(wdb, 'height', node.chain.height);