Skip to content

Commit

Permalink
Merge pull request #106 from nodar-chkuaselidze/fix-tests
Browse files Browse the repository at this point in the history
Fix tests.
  • Loading branch information
nodech authored Nov 16, 2018
2 parents 720f353 + b9d1f6d commit d0d0efb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/chain-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const MemWallet = require('./util/memwallet');
const Network = require('../lib/protocol/network');
const Output = require('../lib/primitives/output');
const common = require('../lib/blockchain/common');
const util = require('../lib/utils/util');
const Opcode = require('../lib/script/opcode');
const opcodes = Script.opcodes;

Expand Down Expand Up @@ -48,6 +49,8 @@ const wallet = new MemWallet({
network
});

const MAA = network.block.magneticAnomalyActivationTime;

let tip1 = null;
let tip2 = null;

Expand Down Expand Up @@ -167,6 +170,10 @@ describe('Chain', function() {
it('should open chain and miner', async () => {
await chain.open();
await miner.open();

// use some time in the future for maa activation
// test should not take more than HOUR
network.block.magneticAnomalyActivationTime = util.now() + 3600;
});

it('should add addrs to miner', async () => {
Expand Down Expand Up @@ -1036,6 +1043,7 @@ describe('Chain', function() {
});

it('should cleanup', async () => {
network.block.magneticAnomalyActivationTime = MAA;
await miner.close();
await chain.close();
});
Expand Down
8 changes: 8 additions & 0 deletions test/node-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Address = require('../lib/primitives/address');
const Peer = require('../lib/net/peer');
const InvItem = require('../lib/primitives/invitem');
const invTypes = InvItem.types;
const util = require('../lib/utils/util');

const node = new FullNode({
memory: true,
Expand All @@ -28,8 +29,12 @@ const node = new FullNode({

const chain = node.chain;
const miner = node.miner;
const network = node.network;
const {wdb} = node.require('walletdb');

// Magnetic Anomaly Activation time
const MAA = network.block.magneticAnomalyActivationTime;

let wallet = null;
let tip1 = null;
let tip2 = null;
Expand Down Expand Up @@ -92,6 +97,8 @@ describe('Node', function() {
it('should open chain and miner', async () => {
miner.mempool = null;
consensus.COINBASE_MATURITY = 0;

network.block.magneticAnomalyActivationTime = util.now() + 3600;
await node.open();
});

Expand Down Expand Up @@ -779,6 +786,7 @@ describe('Node', function() {

it('should cleanup', async () => {
consensus.COINBASE_MATURITY = 100;
network.block.magneticAnomalyActivationTime = MAA;
await node.close();
});
});

0 comments on commit d0d0efb

Please sign in to comment.