Skip to content

Commit

Permalink
fix(period): wrong name for validator address attribute in period opt…
Browse files Browse the repository at this point in the history
…ions (#172)

* fix(period): wrong name for validator address attribute in period options

* update typedef and docs
  • Loading branch information
troggy authored Jan 28, 2020
1 parent bfdc4bc commit fcea469
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ declare module "leap-core" {
type PeriodOptions = {
validatorData?: {
slotId: number;
ownerAddr: string | Buffer | number;
validatorAddress: string | Buffer | number;
casBitmap?: string | Buffer | number;
};
excludePrevHashFromProof?: Boolean;
Expand Down Expand Up @@ -340,7 +340,7 @@ declare module "leap-core" {
};

type PeriodData = {
ownerAddr: string;
validatorAddress: string;
slotId: number;
casBitmap?: string;
periodStart?: number;
Expand Down
4 changes: 2 additions & 2 deletions lib/helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('helpers', () => {
};

const periodOpts = {
validatorData: { slotId: 0, ownerAddr: ADDR_1 },
validatorData: { slotId: 0, validatorAddress: ADDR_1 },
excludePrevHashFromProof: true,
};

Expand Down Expand Up @@ -243,7 +243,7 @@ describe('helpers', () => {
},
getPeriodByBlockHeight: n => {
expect(n).to.be.equal(4);
return Promise.resolve([{ slotId: 0, ownerAddr: ADDR_1, casBitmap }]);
return Promise.resolve([{ slotId: 0, validatorAddress: ADDR_1, casBitmap }]);
},
};

Expand Down
9 changes: 4 additions & 5 deletions lib/period.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class Period {
* type PeriodOptions = {
* validatorData?: {
* slotId: number;
* ownerAddr: string | Buffer | number;
* validatorAddress: string | Buffer | number;
* casBitmap?: string | Buffer | number;
* };
* excludePrevHashFromProof?: Boolean;
Expand All @@ -44,10 +44,9 @@ export default class Period {
if (blocks) {
blocks.forEach(block => this.addBlock(block));
}

const { slotId, ownerAddr, casBitmap } = opts.validatorData || {};
if ((slotId || slotId === 0) && ownerAddr) {
this.setValidatorData(slotId, ownerAddr, casBitmap);
const { slotId, validatorAddress, casBitmap } = opts.validatorData || {};
if ((slotId || slotId === 0) && validatorAddress) {
this.setValidatorData(slotId, validatorAddress, casBitmap);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/period.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const slotId = 4;

const validatorData = {
slotId,
ownerAddr: ADDR
validatorAddress: ADDR
};

/**
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('periods', () => {
const period = new Period(null, [block1, block2], {
validatorData: {
slotId,
ownerAddr: ADDR,
validatorAddress: ADDR,
casBitmap: '0x4000000000000000000000000000000000000000000000000000000000000000'
},
excludePrevHashFromProof: true
Expand Down

0 comments on commit fcea469

Please sign in to comment.