From 29d5085ae2bee92f455101b05468e39b712b55dc Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Tue, 7 Mar 2017 18:12:39 +0100
Subject: [PATCH] [enh] #847 Missing division by (dtReeval / dt)

---
 app/lib/dup/indexer.js                     | 2 +-
 test/fast/block/protocol-brg13-dividend.js | 4 ++--
 test/integration/v1.0-double-dividend.js   | 4 ++--
 test/integration/v1.0-g1-dividend.js       | 8 ++++----
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/app/lib/dup/indexer.js b/app/lib/dup/indexer.js
index f9a71abd7..ad23ea20d 100644
--- a/app/lib/dup/indexer.js
+++ b/app/lib/dup/indexer.js
@@ -840,7 +840,7 @@ const indexer = module.exports = {
     } else if (HEAD.udReevalTime != HEAD_1.udReevalTime) {
       // DUG
       const previousUB = HEAD_1.unitBase;
-      HEAD.dividend = Math.ceil(HEAD_1.dividend + Math.pow(conf.c, 2) * Math.ceil(HEAD_1.mass / Math.pow(10, previousUB)) / HEAD.membersCount);
+      HEAD.dividend = Math.ceil(HEAD_1.dividend + Math.pow(conf.c, 2) * Math.ceil(HEAD_1.mass / Math.pow(10, previousUB)) / HEAD.membersCount / (conf.dtReeval / conf.dt));
     } else {
       HEAD.dividend = HEAD_1.dividend;
     }
diff --git a/test/fast/block/protocol-brg13-dividend.js b/test/fast/block/protocol-brg13-dividend.js
index fb2bedf1e..5673b9806 100644
--- a/test/fast/block/protocol-brg13-dividend.js
+++ b/test/fast/block/protocol-brg13-dividend.js
@@ -25,7 +25,7 @@ describe("Protocol BR_G13 - dividend", function(){
   }));
 
   it('block with medianTime == udTime', () => co(function*(){
-    const conf   = { dt: 100, c: 0.0488 };
+    const conf   = { dt: 100, dtReeval: 100, c: 0.0488 };
     const HEAD_1 = { number: 59, udTime:     1500000900, udReevalTime: 1500000900, dividend: 100, mass: 18000, unitBase: 1 };
     const HEAD   = { number: 60, medianTime: 1500000900, membersCount: 3 };
     indexer.prepareUDTime(HEAD, HEAD_1, conf);
@@ -35,7 +35,7 @@ describe("Protocol BR_G13 - dividend", function(){
   }));
 
   it('block with medianTime > udTime', () => co(function*(){
-    const conf   = { dt: 100, c: 0.0488 };
+    const conf   = { dt: 100, dtReeval: 100, c: 0.0488 };
     const HEAD_1 = { number: 59, udTime:     1500000900, udReevalTime: 1500000900, dividend: 100, mass: 18000, unitBase: 1 };
     const HEAD   = { number: 60, medianTime: 1500000901, membersCount: 3 };
     indexer.prepareUDTime(HEAD, HEAD_1, conf);
diff --git a/test/integration/v1.0-double-dividend.js b/test/integration/v1.0-double-dividend.js
index 7781c7df9..e0b33b369 100644
--- a/test/integration/v1.0-double-dividend.js
+++ b/test/integration/v1.0-double-dividend.js
@@ -78,10 +78,10 @@ describe("Protocol 1.0 Dividend Update", function() {
   }));
 
   it('should have block#8 with UD 1010', () => s1.expectThat('/blockchain/block/8', (json) => {
-    json.dividend.should.equal(1010);
+    json.dividend.should.equal(1002);
   }));
 
   it('should have block#9 with UD 1010', () => s1.expectThat('/blockchain/block/9', (json) => {
-    json.dividend.should.equal(1010);
+    json.dividend.should.equal(1002);
   }));
 });
diff --git a/test/integration/v1.0-g1-dividend.js b/test/integration/v1.0-g1-dividend.js
index 4659467de..b32b9bd6f 100644
--- a/test/integration/v1.0-g1-dividend.js
+++ b/test/integration/v1.0-g1-dividend.js
@@ -80,13 +80,13 @@ describe("Protocol 1.0 Ğ1 Dividend", function() {
     json.should.have.property('medianTime').equal(start + aDay * 11); // 2016-03-20 12:00:00 UTC+0
   }));
 
-  it('should have block#13 with UD 1027', () => s1.expectThat('/blockchain/block/13', (json) => {
-    json.dividend.should.equal(1027);
+  it('should have block#13 with UD 1001', () => s1.expectThat('/blockchain/block/13', (json) => {
+    json.dividend.should.equal(1001);
     json.should.have.property('medianTime').equal(start + aDay * 12); // 2016-03-21 12:00:00 UTC+0
   }));
 
-  it('should have block#14 with UD 1027', () => s1.expectThat('/blockchain/block/14', (json) => {
-    json.dividend.should.equal(1027);
+  it('should have block#14 with UD 1001', () => s1.expectThat('/blockchain/block/14', (json) => {
+    json.dividend.should.equal(1001);
     json.should.have.property('medianTime').equal(start + aDay * 13); // 2016-03-22 12:00:00 UTC+0
   }));
 });
-- 
GitLab