Skip to content

Commit db536bb

Browse files
author
Beau Shinkle
committed
Annotate insertOperator
1 parent 1c087b7 commit db536bb

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

test/sortitionTreeTest.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,22 @@ describe("SortitionTree", () => {
113113
describe("insertOperator", () => {
114114
const weightA = 0xfff0
115115
const weightB = 0x10000001
116+
// weightA + weightB = 0x1000fff1
116117

117118
context("when operators are inserted", () => {
118119
it("should return correct value for the tree", async () => {
120+
// insertion begins left to right, so alice is inserted at position 0,
121+
// and bob is inserted at position 1. Their weights will propagate to
122+
// the root's first slot.
119123
await sortition.publicInsertOperator(alice.address, weightA)
120124
await sortition.publicInsertOperator(bob.address, weightB)
121125
const root = await sortition.getRoot()
122-
expect(ethers.utils.hexlify(root)).to.be.equal("0x1000fff1")
126+
expect(ethers.utils.hexlify(root)).to.be.equal("0x1000fff1") // weightA + weightB
127+
// The full output here looks like
128+
// 0x00000000,00000000,00000000,00000000,00000000,00000000,00000000,1000fff1
129+
// slot 7 slot 6 slot 5 slot 4 slot 3 slot 2 slot 1 slot 0
130+
// without the commas added for readability. All the padding zeros are
131+
// dropped when we hexlify, which simplifies to 0x1100000000.
123132
})
124133
})
125134

0 commit comments

Comments
 (0)