Skip to content

Commit

Permalink
namestate: check for expiration when getting JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed May 24, 2021
1 parent bacae27 commit e9627fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion lib/covenants/namestate.js
Expand Up @@ -651,12 +651,15 @@ class NameState extends bio.Struct {
getJSON(height, network) {
let state = undefined;
let stats = undefined;
let expired = this.expired;

if (height != null) {
network = Network.get(network);
state = this.state(height, network);
state = statesByVal[state];
stats = this.toStats(height, network);

expired = this.isExpired(height, network);
}

return {
Expand All @@ -674,7 +677,7 @@ class NameState extends bio.Struct {
claimed: this.claimed,
renewals: this.renewals,
registered: this.registered,
expired: this.expired,
expired: expired,
weak: this.weak,
stats: stats
};
Expand Down
10 changes: 5 additions & 5 deletions test/namestate-test.js
Expand Up @@ -97,7 +97,7 @@ describe('Namestate', function() {

assert.strictEqual(json.state, 'CLOSED');
assert(json.stats === null);
// TODO: ns.expired should be true
assert(json.expired);
});

it('should be CLOSED until expiration with owner', () => {
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('Namestate', function() {
'blocksSinceExpired'
]
);
// TODO: ns.expired should be true
assert(json.expired);
heightWithOwner++;
}
});
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('Namestate', function() {
'blocksSinceExpired'
]
);
// TODO: ns.expired should be true
assert(json.expired);
heightWithTransfer++;
}
});
Expand Down Expand Up @@ -264,7 +264,7 @@ describe('Namestate', function() {
'blocksSinceExpired'
]
);
// TODO: ns.expired should be true
assert(json.expired);
heightWithRevoke++;
}
});
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('Namestate', function() {
'blocksSinceExpired'
]
);
// TODO: ns.expired should be true
assert(json.expired);
heightWithOwner++;
}
});
Expand Down

0 comments on commit e9627fd

Please sign in to comment.