-
Notifications
You must be signed in to change notification settings - Fork 16
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
block deserialization with dynafed support #25
base: master
Are you sure you want to change the base?
Conversation
add .idea to gitignore @sekulicd |
Please run |
|
||
const readVarInt = (): number => { | ||
const vi = varuint.decode(buffer, offset); | ||
offset += varuint.decode.bytes; | ||
return vi; | ||
}; | ||
|
||
const block = new Block(); | ||
block.version = readUInt32(); |
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.
I would use the BufferReader
from bufferutils.ts
to read the bytes instead of read* functions.
You also need to delete the folder and repush with "deleted |
test/block.spec.ts
Outdated
|
||
describe('block deserialization ', () => { | ||
fixtures.test.forEach(f => { | ||
block.Block.fromBuffer(Buffer.from(f.hex, 'hex')); |
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.
you need to check result is non null? @louisinger
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.
this checks if fromBuffer
throws an error so LGTM. Best way to test is to check if all the block's fields are deserialized but may be hard to make the fixtures
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.
I mean we need an it
ro specify the test
ie.
block.Block.fromBuffer(Buffer.from(f.hex, 'hex')); | |
it('should de-serialize dyna-fed blcoks', () => { | |
const bock = block.Block.fromBuffer(Buffer.from(f.hex, 'hex')); | |
//assert block is non empty | |
}); |
I added another test fixture for a block with compact current and null proposed params taken from https://github.com/ElementsProject/rust-elements/blob/acc702c/src/block.rs#L653 and added assertions to check the expected block hash, version, and signBlockWitnessLimit, along with number of transactions. The block hashes resulting from block.getHash() are not matching those expected by the tests in rust-elements. Any ideas why? |
cc/ @sekulicd |
thanks @asoltys @sekulicd can you cherry-pick his commit to add the test? asoltys@4a0bb0c |
@sekulicd @tiero @louisinger what's the status of this? |
Has been tested by @asoltys and confirmed was working, but we miss to clean it up, solve conflicts etc.. for proper merge in master branch |
This adds supports to deserialise dynafed block.
This closes #23
@tiero @asoltys please review.