Skip to content

Commit

Permalink
Merge branch 'development' into testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
vekexasia committed Sep 20, 2018
2 parents b9887c1 + 81009b3 commit 375ec56
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/AppManager.ts
Expand Up @@ -25,6 +25,7 @@ import { PostTransactionsRequest } from './apis/requests/PostTransactionsRequest
import { requestSymbols } from './apis/requests/requestSymbols';
import { AttachPeerHeaders } from './apis/utils/attachPeerHeaders';
import { ForgingApisWatchGuard } from './apis/utils/forgingApisWatchGuard';
import { RestrictedAPIWatchGuard } from './apis/utils/restrictedAPIWatchGuard';
import { SuccessInterceptor } from './apis/utils/successInterceptor';
import { V2APIErrorHandler } from './apis/utils/v2ErrorHandler';
import { ValidatePeerHeaders } from './apis/utils/validatePeerHeaders';
Expand Down Expand Up @@ -271,6 +272,7 @@ export class AppManager {
this.container.bind(Symbols.api.utils.v2ErrorHandler).to(V2APIErrorHandler).inSingletonScope();
this.container.bind(Symbols.api.utils.successInterceptor).to(SuccessInterceptor).inSingletonScope();
this.container.bind(Symbols.api.utils.forgingApisWatchGuard).to(ForgingApisWatchGuard).inSingletonScope();
this.container.bind(Symbols.api.utils.restrictedWhiteList).to(RestrictedAPIWatchGuard).inSingletonScope();
this.container.bind(Symbols.api.utils.validatePeerHeadersMiddleware).to(ValidatePeerHeaders).inSingletonScope();
this.container.bind(Symbols.api.utils.attachPeerHeaderToResponseObject).to(AttachPeerHeaders).inSingletonScope();

Expand Down
6 changes: 4 additions & 2 deletions tests/integration/api/transactions.spec.ts
Expand Up @@ -4,7 +4,7 @@ import { ITransaction } from 'dpos-offline/dist/es5/trxTypes/BaseTx';
import * as supertest from 'supertest';
import initializer from '../common/init';
// tslint:disable-next-line
import { constants, TransactionType } from '../../../src/helpers';
import {constants, TransactionType, wait} from '../../../src/helpers';
import { ITransactionPoolLogic } from '../../../src/ioc/interfaces/logic';
import { IBlocksModule, ITransactionsModule } from '../../../src/ioc/interfaces/modules';
import { Symbols } from '../../../src/ioc/symbols';
Expand Down Expand Up @@ -421,9 +421,11 @@ describe('api/transactions', () => {
.post('/api/transactions')
.send({secret: s, recipientId: createRandomWallet().address, amount: 10})
.expect(200)
.then((r) => {
.then(async (r) => {
console.log(r.body);
expect(r.body.success).true;
expect(r.body.transactionId).not.empty;
await wait(1000);
expect(txPool.transactionInPool(r.body.transactionId)).is.true;
});
});
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/api/transportV2.spec.ts
Expand Up @@ -665,7 +665,7 @@ describe('v2/peer/transport', function() {
.get('/v2/peer/blocks/'));

it('should query last blocks from given lastId', async () => {
const nBlocks = 200;
const nBlocks = 80;
const txsPerBlock = 10;
const blocks = [];
const wallets = [];
Expand Down Expand Up @@ -708,7 +708,9 @@ describe('v2/peer/transport', function() {
delete blk.relays;
return blk;
});
expect(r.blocks).to.be.deep.equal(blocks);
for (let i = 0; i < r.blocks.length; i++) {
expect(r.blocks[i]).deep.eq(blocks[i]);
}
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/config.json
Expand Up @@ -32,7 +32,7 @@
"public": true,
"whiteList": ["127.0.0.1"]
},
"restrictedWhiteList": [ "127.0.0.1" ],
"restrictedWhiteList": [ "127.0.0.1", "::ffff:127.0.0.1" ],
"options": {
"limits": {
"max": 0,
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/AppManager.spec.ts
Expand Up @@ -465,7 +465,7 @@ describe('AppManager', () => {
// Test added to make sure this file is updated every time a new element is bound in container
it('should call bind exactly 100 times', async () => {
await instance.initAppElements();
expect(containerStub.bindCount).to.be.equal(100);
expect(containerStub.bindCount).to.be.equal(101);
});

it('should bind each API controller to its symbol', async () => {
Expand Down Expand Up @@ -508,6 +508,13 @@ describe('AppManager', () => {
to : 'AttachPeerHeaders',
},
]);

expect(containerStub.bindings[Symbols.api.utils.restrictedWhiteList]).to.be.deep.equal([
{
inSingletonScope: true,
to : 'RestrictedAPIWatchGuard',
},
]);
});

it('should bind each generic to its symbol', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/helpers/config.spec.ts
Expand Up @@ -9,9 +9,9 @@ const config = proxyquire('../../../src/helpers/config', {

// config() sometimes does console.log, this function disables console.log before the call and re-enables it after.
const muteConfig = (path) => {
const unmute = mute();
// const unmute = mute();
const cfg = config(path);
unmute();
// unmute();
return cfg;
};

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/helpers/data/validConfig.json
Expand Up @@ -36,6 +36,7 @@
"127.0.0.1"
]
},
"restrictedWhiteList": [ "127.0.0.1" ],
"options": {
"limits": {
"max": 0,
Expand Down Expand Up @@ -112,4 +113,4 @@
"autoexec": []
},
"nethash": "cd8171332c012514864edd8eb6f68fc3ea6cb2afbaf21c56e12751022684cea5"
}
}

0 comments on commit 375ec56

Please sign in to comment.