diff --git a/test/auction-reorg-test.js b/test/auction-reorg-test.js index 2b50436e0..d1e8d5cb7 100644 --- a/test/auction-reorg-test.js +++ b/test/auction-reorg-test.js @@ -12,7 +12,7 @@ const MemWallet = require('./util/memwallet'); const Network = require('../lib/protocol/network'); const rules = require('../lib/covenants/rules'); const {ownership} = require('../lib/covenants/ownership'); -const {CachedStubResolver} = require('./util/stub'); +const {CachedStubResolver, STUB_SERVERS} = require('./util/stub'); const network = Network.get('regtest'); const {treeInterval} = network.names; @@ -75,13 +75,16 @@ describe('Auction Reorg', function() { this.timeout(20000); const originalResolver = ownership.Resolver; + const originalServers = ownership.servers; before(() => { ownership.Resolver = CachedStubResolver; + ownership.servers = STUB_SERVERS; }); after(() => { ownership.Resolver = originalResolver; + ownership.servers = originalServers; }); describe('Vickrey Auction Reorg', function() { diff --git a/test/auction-test.js b/test/auction-test.js index 6a712bc9e..155a17262 100644 --- a/test/auction-test.js +++ b/test/auction-test.js @@ -9,7 +9,7 @@ const MemWallet = require('./util/memwallet'); const Network = require('../lib/protocol/network'); const rules = require('../lib/covenants/rules'); const {ownership} = require('../lib/covenants/ownership'); -const {CachedStubResolver} = require('./util/stub'); +const {CachedStubResolver, STUB_SERVERS} = require('./util/stub'); const network = Network.get('regtest'); const GNAME_SIZE = 10; @@ -71,13 +71,16 @@ describe('Auction', function() { this.timeout(15000); const originalResolver = ownership.Resolver; + const originalServers = ownership.servers; before(() => { ownership.Resolver = CachedStubResolver; + ownership.servers = STUB_SERVERS; }); after(() => { ownership.Resolver = originalResolver; + ownership.servers = originalServers; }); describe('Vickrey Auction', function() { diff --git a/test/chain-checkpoints-test.js b/test/chain-checkpoints-test.js index 0c26ff4c9..09f25dbf8 100644 --- a/test/chain-checkpoints-test.js +++ b/test/chain-checkpoints-test.js @@ -13,7 +13,7 @@ const Network = require('../lib/protocol/network'); const rules = require('../lib/covenants/rules'); const {Resource} = require('../lib/dns/resource'); const AirdropProof = require('../lib/primitives/airdropproof'); -const {CachedStubResolver} = require('./util/stub'); +const {CachedStubResolver, STUB_SERVERS} = require('./util/stub'); const network = Network.get('regtest'); @@ -93,10 +93,12 @@ async function mineBlocks(n, label) { describe('Checkpoints', function() { const originalResolver = ownership.Resolver; + const originalServers = ownership.servers; before(async () => { ownership.ignore = true; ownership.Resolver = CachedStubResolver; + ownership.servers = STUB_SERVERS; await blocks.open(); await chainGenerator.open(); @@ -104,12 +106,13 @@ describe('Checkpoints', function() { }); after(async () => { + ownership.ignore = false; + ownership.Resolver = originalResolver; + ownership.servers = originalServers; + await miner.close(); await chainGenerator.close(); await blocks.close(); - - ownership.ignore = false; - ownership.Resolver = originalResolver; }); it('should add addrs to miner', async () => { diff --git a/test/chain-icann-lockup-test.js b/test/chain-icann-lockup-test.js index 52bfc1c30..56c68d8c2 100644 --- a/test/chain-icann-lockup-test.js +++ b/test/chain-icann-lockup-test.js @@ -10,7 +10,7 @@ const chainCommon = require('../lib/blockchain/common'); const {BufferMap} = require('buffer-map'); const {thresholdStates} = chainCommon; const {isReserved, isLockedUp, hashName} = require('../lib/covenants/rules'); -const {CachedStubResolver} = require('./util/stub'); +const {CachedStubResolver, STUB_SERVERS} = require('./util/stub'); const SOFT_FORK_NAME = 'icannlockup'; @@ -54,13 +54,16 @@ describe('BIP9 - ICANN lockup (integration)', function() { this.timeout(20000); const originalResolver = ownership.Resolver; + const originalServers = ownership.servers; before(() => { ownership.Resolver = CachedStubResolver; + ownership.servers = STUB_SERVERS; }); after(() => { ownership.Resolver = originalResolver; + ownership.servers = originalServers; }); const CUSTOM = [ diff --git a/test/claim-test.js b/test/claim-test.js index 264394a8e..26cbc1392 100644 --- a/test/claim-test.js +++ b/test/claim-test.js @@ -9,7 +9,7 @@ const consensus = require('../lib/protocol/consensus'); const {ownership} = require('../lib/covenants/ownership'); const reserved = require('../lib/covenants/reserved'); const {Resource} = require('../lib/dns/resource'); -const {CachedStubResolver} = require('./util/stub'); +const {CachedStubResolver, STUB_SERVERS} = require('./util/stub'); const network = Network.get('regtest'); @@ -49,18 +49,22 @@ describe('Reserved Name Claims', function() { this.timeout(10000); const originalResolver = ownership.Resolver; + const originalServers = ownership.servers; before(async () => { + ownership.Resolver = CachedStubResolver; + ownership.servers = STUB_SERVERS; + await node.open(); wallet = await wdb.create(); addr = await wallet.receiveAddress(); - ownership.Resolver = CachedStubResolver; }); after(async () => { - await node.close(); ownership.Resolver = originalResolver; + ownership.servers = originalServers; + await node.close(); }); // Reset the ownership flag after every test, diff --git a/test/mempool-invalidation-test.js b/test/mempool-invalidation-test.js index 6caff479a..120d781e1 100644 --- a/test/mempool-invalidation-test.js +++ b/test/mempool-invalidation-test.js @@ -8,7 +8,7 @@ const rules = require('../lib/covenants/rules'); const {states} = require('../lib/covenants/namestate'); const {Resource} = require('../lib/dns/resource'); const {forEvent} = require('./util/common'); -const {CachedStubResolver} = require('./util/stub'); +const {CachedStubResolver, STUB_SERVERS} = require('./util/stub'); const NodeContext = require('./util/node-context'); const network = Network.get('regtest'); @@ -23,13 +23,16 @@ const ACTUAL_RENEWAL_WINDOW = renewalWindow; describe('Mempool Invalidation', function() { const originalResolver = ownership.Resolver; + const originalServers = ownership.servers; before(() => { ownership.Resolver = CachedStubResolver; + ownership.servers = STUB_SERVERS; }); after(() => { ownership.Resolver = originalResolver; + ownership.servers = originalServers; }); const NAMES = [ diff --git a/test/mempool-test.js b/test/mempool-test.js index 6c8ab73ac..7d3fa14c3 100644 --- a/test/mempool-test.js +++ b/test/mempool-test.js @@ -33,7 +33,7 @@ const rules = require('../lib/covenants/rules'); const NameState = require('../lib/covenants/namestate'); const {states} = NameState; const {ownership} = require('../lib/covenants/ownership'); -const {CachedStubResolver} = require('./util/stub'); +const {CachedStubResolver, STUB_SERVERS} = require('./util/stub'); const ONE_HASH = Buffer.alloc(32, 0x00); ONE_HASH[0] = 0x01; @@ -77,13 +77,16 @@ describe('Mempool', function() { this.timeout(5000); const originalResolver = ownership.Resolver; + const originalServers = ownership.servers; before(() => { ownership.Resolver = CachedStubResolver; + ownership.servers = STUB_SERVERS; }); after(() => { ownership.Resolver = originalResolver; + ownership.servers = originalServers; }); describe('Mempool TXs', function() { diff --git a/test/txstart-test.js b/test/txstart-test.js index c40d502aa..2d349e92b 100644 --- a/test/txstart-test.js +++ b/test/txstart-test.js @@ -14,7 +14,7 @@ const Address = require('../lib/primitives/address'); const Script = require('../lib/script/script'); const common = require('../lib/blockchain/common'); const {ownership} = require('../lib/covenants/ownership'); -const {CachedStubResolver} = require('./util/stub'); +const {CachedStubResolver, STUB_SERVERS} = require('./util/stub'); const VERIFY_NONE = common.flags.VERIFY_NONE; const node = new FullNode({ @@ -51,21 +51,24 @@ describe('Disable TXs', function() { let utxo, lastTX; const originalResolver = ownership.Resolver; + const originalServers = ownership.servers; before(async () => { + ownership.Resolver = CachedStubResolver; + ownership.servers = STUB_SERVERS; node.network.txStart = 5; await node.open(); // Start with one block for the fakeClaim const block = await node.miner.mineBlock(); assert(await node.chain.add(block)); - ownership.Resolver = CachedStubResolver; }); after(async () => { - await node.close(); node.network.txStart = RESET_TXSTART; ownership.Resolver = originalResolver; + ownership.servers = originalServers; + await node.close(); }); it('should reject tx from mempool before txStart', async () => { diff --git a/test/util/stub.js b/test/util/stub.js index 5ce561743..75045ef09 100644 --- a/test/util/stub.js +++ b/test/util/stub.js @@ -87,3 +87,5 @@ class CachedStubResolver extends StubResolver { } exports.CachedStubResolver = CachedStubResolver; + +exports.STUB_SERVERS = ['1.1.1.1', '1.0.0.1']; diff --git a/test/wallet-test.js b/test/wallet-test.js index d79637807..b7b267c1e 100644 --- a/test/wallet-test.js +++ b/test/wallet-test.js @@ -25,6 +25,8 @@ const Wallet = require('../lib/wallet/wallet'); const rules = require('../lib/covenants/rules'); const {forValue} = require('./util/common'); const wutils = require('./util/wallet'); +const {ownership} = require('../lib/covenants/ownership'); +const {CachedStubResolver, STUB_SERVERS} = require('./util/stub'); const { dummyInput, curBlock, @@ -55,6 +57,19 @@ let watchWallet = null; describe('Wallet', function() { this.timeout(5000); + const originalResolver = ownership.Resolver; + const originalServers = ownership.servers; + + before(() => { + ownership.Resolver = CachedStubResolver; + ownership.servers = STUB_SERVERS; + }); + + after(() => { + ownership.Resolver = originalResolver; + ownership.servers = originalServers; + }); + it('should open walletdb', async () => { network.coinbaseMaturity = 1; await wdb.open();