Skip to content

Commit

Permalink
🚨 Restored Typescript type checking in tests and removed useless buil…
Browse files Browse the repository at this point in the history
…d file.

🐛 better exception handling
  • Loading branch information
vekexasia committed Oct 23, 2018
1 parent dd15b9e commit 8f2ca8f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Empty file removed build
Empty file.
10 changes: 8 additions & 2 deletions src/exceptions/wrong_rec_exceptions.ts
Expand Up @@ -9,7 +9,7 @@ import { VoteAsset } from '../logic/transactions';
*/
export default function wrongRecExceptions(excManager: ExceptionsManager) {
const handler: IExceptionHandler<ITransactionLogic> = {
canHandle(obj: ITransactionLogic, tx: IBaseTransaction<VoteAsset>) {
canHandle(obj: ITransactionLogic, tx: IBaseTransaction<void>) {
return (
// height 501714 - address exceeding uint64
tx.id === '17611172093035974263' &&
Expand All @@ -21,7 +21,13 @@ export default function wrongRecExceptions(excManager: ExceptionsManager) {
tx.signature.toString('hex') === '6bdd0c83217230b809893a2b3ca301994398be276ff7858870bebfa63cc5e671fe5c8ecdf53c52a47572958363d7721510d5dbcf49b4aca633df5fc758b1a704'
);
},
handle() {
handle(obj: ITransactionLogic, tx: IBaseTransaction<void>) {
const valid = (tx.id === '17611172093035974263' && tx.recipientId === '97269111055079944786R')
||
(tx.id === '6132221392997475140' && tx.recipientId === '910097905859080079914R');
if (!valid) {
return Promise.reject(new Error(`Invalid exception transaction ${tx.id}`));
}
return Promise.resolve();
},
};
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/api/transportV2.spec.ts
Expand Up @@ -257,7 +257,7 @@ describe('v2/peer/transport', function() {
let peer: IPeerLogic;

let getPeersListFactory: RequestFactoryType<void, PeersListRequest>;
let ptFactory: RequestFactoryType<{transactions: Array<IBaseTransaction<any>>}, PostTransactionsRequest>;
let ptFactory: RequestFactoryType<{transactions: Array<IBaseTransaction<any>>} |{ transaction: IBaseTransaction<any>}, PostTransactionsRequest>;
let psFactory: RequestFactoryType<PostSignaturesRequestDataType, PostSignaturesRequest>;
let gsFactory: RequestFactoryType<void, GetSignaturesRequest>;
let gtFactory: RequestFactoryType<void, GetTransactionsRequest>;
Expand Down Expand Up @@ -555,7 +555,7 @@ describe('v2/peer/transport', function() {
const tx1 = await createSendTransaction(0, 1, account, createRandomWallet().address);
const tx2 = await createSendTransaction(0, 2, account, createRandomWallet().address);
const r = await peer.makeRequest(ptFactory({
data: { transactions: [tx1, tx2] } as any,
data: { transactions: [tx1, tx2].map(toBufferedTransaction) },
}));
expect(r.success).to.be.true;
await txPool.processBundled();
Expand Down Expand Up @@ -597,8 +597,8 @@ describe('v2/peer/transport', function() {
const tx = await createSendTransaction(0, 1, account, createRandomWallet().address);
const res = await peer.makeRequest(ptFactory({
data: {
transaction: tx,
} as any,
transaction: toBufferedTransaction(tx),
} ,
}));
expect(res.success).to.be.true;
expect(txPool.transactionInPool(tx.id)).is.true;
Expand All @@ -609,8 +609,8 @@ describe('v2/peer/transport', function() {
// const tx2 = await createSendTransaction(0, 1, account, createRandomWallet().address);
await peer.makeRequest(ptFactory({
data: {
transactions: [tx, tx],
} as any,
transactions: [tx, tx].map(toBufferedTransaction),
} ,
}));
expect(txPool.bundled.has(tx.id)).to.be.true;
});
Expand Down Expand Up @@ -767,7 +767,7 @@ describe('v2/peer/transport', function() {
});

it('should reject block if payloadHash is not ok', async () => {
blockBuf.transactions[0] = await createSendTransaction(0, 1, senderAccount, senderAccount.address, { timestamp: 10 }) as any;
blockBuf.transactions[0] = toBufferedTransaction(await createSendTransaction(0, 1, senderAccount, senderAccount.address, { timestamp: 10 })) as any;
await expect(peer.makeRequest(pbFactory({
data: { block: blockBuf },
}))).rejectedWith('Invalid payload hash');
Expand Down

0 comments on commit 8f2ca8f

Please sign in to comment.