From e9627fd4930adace57f517705d7cd1da35316bb6 Mon Sep 17 00:00:00 2001 From: Matthew Zipkin Date: Mon, 24 May 2021 12:39:50 -0400 Subject: [PATCH] namestate: check for expiration when getting JSON --- lib/covenants/namestate.js | 5 ++++- test/namestate-test.js | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/covenants/namestate.js b/lib/covenants/namestate.js index 5fbd7ca18..f33652461 100644 --- a/lib/covenants/namestate.js +++ b/lib/covenants/namestate.js @@ -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 { @@ -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 }; diff --git a/test/namestate-test.js b/test/namestate-test.js index fbd350b79..9288a3a72 100644 --- a/test/namestate-test.js +++ b/test/namestate-test.js @@ -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', () => { @@ -139,7 +139,7 @@ describe('Namestate', function() { 'blocksSinceExpired' ] ); - // TODO: ns.expired should be true + assert(json.expired); heightWithOwner++; } }); @@ -190,7 +190,7 @@ describe('Namestate', function() { 'blocksSinceExpired' ] ); - // TODO: ns.expired should be true + assert(json.expired); heightWithTransfer++; } }); @@ -264,7 +264,7 @@ describe('Namestate', function() { 'blocksSinceExpired' ] ); - // TODO: ns.expired should be true + assert(json.expired); heightWithRevoke++; } }); @@ -338,7 +338,7 @@ describe('Namestate', function() { 'blocksSinceExpired' ] ); - // TODO: ns.expired should be true + assert(json.expired); heightWithOwner++; } });