Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
Added tests for RLP.getLength
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Feb 15, 2018
1 parent df43db0 commit d99f8ac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ describe('RLP encoding (string):', function () {
it('should return itself if single byte and less than 0x7f:', function () {
var encodedSelf = RLP.encode('a')
assert.equal(encodedSelf.toString(), 'a')
assert.equal(RLP.getLength(encodedSelf), 1)
})

it('length of string 0-55 should return (0x80+len(data)) plus data', function () {
var encodedDog = RLP.encode('dog')
assert.equal(4, encodedDog.length)
assert.equal(RLP.getLength(encodedDog), 4)
assert.equal(encodedDog[0], 131)
assert.equal(encodedDog[1], 100)
assert.equal(encodedDog[2], 111)
Expand All @@ -33,6 +35,7 @@ describe('RLP encoding (string):', function () {
it('length of string >55 should return 0xb7+len(len(data)) plus len(data) plus data', function () {
var encodedLongString = RLP.encode('zoo255zoo255zzzzzzzzzzzzssssssssssssssssssssssssssssssssssssssssssssss')
assert.equal(72, encodedLongString.length)
assert.equal(RLP.getLength(encodedLongString), 2)
assert.equal(encodedLongString[0], 184)
assert.equal(encodedLongString[1], 70)
assert.equal(encodedLongString[2], 122)
Expand Down

0 comments on commit d99f8ac

Please sign in to comment.