Skip to content

Commit

Permalink
Merge branch '1260-default-transactiondepth-must-be-zero' into '1.6'
Browse files Browse the repository at this point in the history
Resolve "default TransactionDepth must be zero"

Closes #1260

See merge request nodes/typescript/duniter!1239
  • Loading branch information
Éloïs committed Jan 25, 2018
2 parents 0ecc4a2 + 54eb7f3 commit b294237
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/lib/rules/local_rules.ts
Expand Up @@ -385,7 +385,7 @@ export const LOCAL_RULES_FUNCTIONS = {
const sindex = Indexer.sindex(index)
const max = getMaxTransactionDepth(sindex)
//
const allowedMax = block.medianTime > 1519862400 ? CommonConstants.BLOCK_MAX_TX_CHAINING_DEPTH : 1
const allowedMax = block.medianTime > 1519862400 ? CommonConstants.BLOCK_MAX_TX_CHAINING_DEPTH : 0
if (max > allowedMax) {
throw "The maximum transaction chaining length per block is " + CommonConstants.BLOCK_MAX_TX_CHAINING_DEPTH
}
Expand Down
10 changes: 6 additions & 4 deletions test/integration/transactions-chaining.ts
@@ -1,7 +1,6 @@
import {CommonConstants} from "../../app/lib/common-libs/constants"
import {TestUser} from "./tools/TestUser"
import {TestingServer} from "./tools/toolbox"
import {NewLogger} from "../../app/lib/logger"

const should = require('should');
const assert = require('assert');
Expand Down Expand Up @@ -71,9 +70,12 @@ describe("Transaction chaining", () => {
CommonConstants.TRANSACTION_MAX_TRIES = 2;
await unit.shouldNotFail(toc.sendTX(tx1));
await unit.shouldNotFail(toc.sendTX(tx2));
(await s1.get('/tx/sources/DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo')).should.have.property('sources').length(1);
(await s1.get('/tx/sources/DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV')).should.have.property('sources').length(1);
await s1.commit({ time: now + 7210 }); // TX1 + TX2 commited
(await s1.get('/tx/sources/DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo')).should.have.property('sources').length(1); // 1200
(await s1.get('/tx/sources/DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV')).should.have.property('sources').length(1); // 1200
await s1.commit({ time: now + 7210 }); // TX1 commited only
(await s1.get('/tx/sources/DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo')).should.have.property('sources').length(1); // 1200 - 1040 = 160 remaining
(await s1.get('/tx/sources/DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV')).should.have.property('sources').length(2); // The UD + 1040 units sent by toc
await s1.commit({ time: now + 7210 }); // TX2 commited now (cause it couldn't be chained before)
(await s1.get('/tx/sources/DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo')).should.have.property('sources').length(0);
(await s1.get('/tx/sources/DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV')).should.have.property('sources').length(3); // The UD + 1040 + 160 units sent by toc
CommonConstants.TRANSACTION_MAX_TRIES = tmp;
Expand Down

0 comments on commit b294237

Please sign in to comment.