-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit tests for cache, convert it to es6 class #427
Conversation
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love to have this documented now, everything fine, will merge.
constructor (trie) { | ||
this._cache = Tree() | ||
this._checkpoints = [] | ||
this._trie = trie | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, equivalent.
let account = this.lookup(key) | ||
if (!account) { | ||
account = new Account() | ||
} | ||
return account | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put
and get
equivalent, ok, like this explicit addition of the default false
value for fromTrie
.
const account = new Account(it.value.val) | ||
return account | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
if (err) return cb(err) | ||
self._update(key, account, false, false) | ||
var account = new Account(raw) | ||
cb(null, account) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
cb(null, account) | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With addition of nextTick
, ok.
it.value.val = (new Account()).serialize() | ||
self._trie.del(Buffer.from(it.key, 'hex'), function () { | ||
}, cb) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
async.nextTick(done) | ||
} | ||
}, cb) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a `nextTick' addition, ok.
modified: modified, | ||
deleted: deleted | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything ok, looked for change equivalency and completeness.
|
||
st.end() | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice test addition, great!
@@ -242,7 +242,6 @@ function runTests (name, runnerArgs, cb) { | |||
|
|||
function runAll () { | |||
require('./tester.js') | |||
require('./cacheTest.js') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, think it's safe to remove.
Just for info: have set For |
tests/cacheTest.js
, as it hasn't been in use for some time (and it doesn't seem related to cache?) (see also cacheTest.js still references.trie
instead of the new._trie
#426)