diff --git a/convex-core/src/main/java/convex/core/cvm/State.java b/convex-core/src/main/java/convex/core/cvm/State.java index 44a9ad3a8..66fe3f432 100644 --- a/convex-core/src/main/java/convex/core/cvm/State.java +++ b/convex-core/src/main/java/convex/core/cvm/State.java @@ -642,6 +642,10 @@ public State putAccount(Address address, AccountStatus accountStatus) { */ public AccountStatus getAccount(Address target) { long ix=target.longValue(); + return getAccount(ix); + } + + public AccountStatus getAccount(long ix) { AVector accts=getAccounts(); if ((ix<0)||(ix>=accts.count())) return null; return accts.get(ix); @@ -725,11 +729,6 @@ public void validate() throws InvalidDataException { super.validate(); } - @Override - public void validateCell() throws InvalidDataException { - // nothing to do? - } - /** * Gets the current global timestamp from this state. * @@ -739,6 +738,11 @@ public CVMLong getTimestamp() { return (CVMLong) getGlobals().get(GLOBAL_TIMESTAMP); } + @Override + public void validateCell() throws InvalidDataException { + // nothing to do? + } + /** * Gets the current Juice price * @@ -960,4 +964,6 @@ protected State withValues(AVector newValues) { + + } diff --git a/convex-core/src/test/java/convex/core/init/InitTest.java b/convex-core/src/test/java/convex/core/init/InitTest.java index 2805f74ea..206343b69 100644 --- a/convex-core/src/test/java/convex/core/init/InitTest.java +++ b/convex-core/src/test/java/convex/core/init/InitTest.java @@ -18,13 +18,17 @@ import convex.core.cvm.PeerStatus; import convex.core.cvm.State; import convex.core.data.AccountKey; +import convex.core.data.Blob; +import convex.core.data.Format; import convex.core.data.Hash; import convex.core.data.MapEntry; import convex.core.data.Ref; import convex.core.data.Refs; import convex.core.data.prim.CVMLong; +import convex.core.exceptions.BadFormatException; import convex.core.exceptions.InvalidDataException; import convex.core.lang.ACVMTest; +import convex.core.lang.Core; /** * Tests for Init functionality @@ -115,6 +119,16 @@ public void testMemoryExchange() { assertEquals(Constants.INITIAL_MEMORY_POOL*Constants.INITIAL_MEMORY_PRICE,cvx.longValue()); } + @Test + public void testInitEncoding() throws BadFormatException { + Blob b=Format.encodeMultiCell(STATE, true); + + State s=Format.decodeMultiCell(b); + assertEquals(STATE,s); + assertEquals(STATE.getAccount(Core.CORE_ADDRESS),s.getAccount(Core.CORE_ADDRESS)); + assertEquals(STATE.getAccount(29),s.getAccount(29)); + } + @Test public void testInitRef() { State s=STATE;