fix render missing field in premix report page

This commit is contained in:
andri lim 2019-01-15 23:29:53 +07:00 committed by zah
parent c98e337090
commit 691dc5566f
1 changed files with 32 additions and 0 deletions

View File

@ -98,6 +98,26 @@ function opCodeRenderer(txId, nimbus, geth) {
return true;
}
function fillEmptyList(a, b) {
if(a.length > b.length) {
for(var i in a) {
if(b[i] === undefined) {
b[i] = '';
}
}
}
}
function fillEmptyMap(a, b) {
if(Object.keys(a).length > Object.keys(b).length) {
for(var i in a) {
if(b[i] === undefined) {
b[i] = '';
}
}
}
}
function analyze(nimbus, geth) {
for(var x of premix.fields) {
if(nimbus[x] === undefined) nimbus[x] = '';
@ -105,6 +125,15 @@ function opCodeRenderer(txId, nimbus, geth) {
if(nimbus[x].toString().toLowerCase() != geth[x].toString().toLowerCase()) return false;
}
fillEmptyList(nimbus.memory, geth.memory);
fillEmptyList(geth.memory, nimbus.memory);
fillEmptyList(nimbus.stack, geth.stack);
fillEmptyList(geth.stack, nimbus.stack);
fillEmptyMap(nimbus.storage, geth.storage);
fillEmptyMap(geth.storage, nimbus.storage);
let result = analyzeList(nimbus.memory, geth.memory);
result = result && analyzeList(nimbus.stack, geth.stack);
result = result && analyzeList(nimbus.storage, geth.storage);
@ -133,6 +162,9 @@ function opCodeRenderer(txId, nimbus, geth) {
fillEmptyOp(ncs, gcs);
fillEmptyOp(gcs, ncs);
console.log(ncs[0]);
console.log(gcs[0]);
for(var i in ncs) {
var pc = ncs[i];
if(!analyze(ncs[i], gcs[i])) {