diff --git a/convex-core/src/main/java/convex/core/cvm/PeerStatus.java b/convex-core/src/main/java/convex/core/cvm/PeerStatus.java index f1a3fbcdb..5a0dbc6c0 100644 --- a/convex-core/src/main/java/convex/core/cvm/PeerStatus.java +++ b/convex-core/src/main/java/convex/core/cvm/PeerStatus.java @@ -265,12 +265,12 @@ public PeerStatus withPeerStake(long newStake) { if (peerStake == newStake) return this; long stakeChange=newStake-peerStake; - return new PeerStatus(controller, newStake, stakes, delegatedStake, metadata,timestamp,balance+stakeChange); + return new PeerStatus(controller, newStake, getStakes(), delegatedStake, getMetadata(),timestamp,balance+stakeChange); } public PeerStatus withPeerData(AHashMap newMeta) { if (metadata==newMeta) return this; - return new PeerStatus(controller, peerStake, stakes, delegatedStake, newMeta,timestamp,balance); + return new PeerStatus(controller, peerStake, getStakes(), delegatedStake, newMeta,timestamp,balance); } @Override @@ -283,12 +283,12 @@ public void validateCell() throws InvalidDataException { @Override public ACell get(Keyword key) { if (Keywords.CONTROLLER.equals(key)) return controller; - if (Keywords.STAKE.equals(key)) return CVMLong.create(peerStake); + if (Keywords.STAKE.equals(key)) return values.get(1); if (Keywords.STAKES.equals(key)) return getStakes(); - if (Keywords.DELEGATED_STAKE.equals(key)) return CVMLong.create(delegatedStake); + if (Keywords.DELEGATED_STAKE.equals(key)) return values.get(3); if (Keywords.METADATA.equals(key)) return getMetadata(); - if (Keywords.TIMESTAMP.equals(key)) return CVMLong.create(timestamp); - if (Keywords.BALANCE.equals(key)) return CVMLong.create(balance); + if (Keywords.TIMESTAMP.equals(key)) return values.get(5); + if (Keywords.BALANCE.equals(key)) return values.get(6); return null; } diff --git a/convex-core/src/test/java/convex/core/data/PeerStatusTest.java b/convex-core/src/test/java/convex/core/data/PeerStatusTest.java index 48247fafe..ef548bfbb 100644 --- a/convex-core/src/test/java/convex/core/data/PeerStatusTest.java +++ b/convex-core/src/test/java/convex/core/data/PeerStatusTest.java @@ -1,5 +1,6 @@ package convex.core.data; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -7,6 +8,7 @@ import convex.core.cvm.Address; import convex.core.cvm.Keywords; import convex.core.cvm.PeerStatus; +import convex.core.data.prim.CVMLong; import convex.core.exceptions.InvalidDataException; import convex.core.util.Utils; @@ -14,6 +16,8 @@ public class PeerStatusTest { @Test public void testEmpty() { PeerStatus ps=PeerStatus.create(null, 0); + + assertEquals(CVMLong.ZERO,ps.get(Keywords.DELEGATED_STAKE)); doPeerStatusTest(ps); }