Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: change ownership resolver from google to cloudflare. #895

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion test/auction-reorg-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 4 additions & 1 deletion test/auction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
11 changes: 7 additions & 4 deletions test/chain-checkpoints-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -93,23 +93,26 @@ 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();
await miner.open();
});

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 () => {
Expand Down
5 changes: 4 additions & 1 deletion test/chain-icann-lockup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 = [
Expand Down
10 changes: 7 additions & 3 deletions test/claim-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion test/mempool-invalidation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 = [
Expand Down
5 changes: 4 additions & 1 deletion test/mempool-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
9 changes: 6 additions & 3 deletions test/txstart-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 () => {
Expand Down
2 changes: 2 additions & 0 deletions test/util/stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ class CachedStubResolver extends StubResolver {
}

exports.CachedStubResolver = CachedStubResolver;

exports.STUB_SERVERS = ['1.1.1.1', '1.0.0.1'];
15 changes: 15 additions & 0 deletions test/wallet-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
Loading