File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
main/java/convex/core/cvm
test/java/convex/core/init Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -642,6 +642,10 @@ public State putAccount(Address address, AccountStatus accountStatus) {
642
642
*/
643
643
public AccountStatus getAccount (Address target ) {
644
644
long ix =target .longValue ();
645
+ return getAccount (ix );
646
+ }
647
+
648
+ public AccountStatus getAccount (long ix ) {
645
649
AVector <AccountStatus > accts =getAccounts ();
646
650
if ((ix <0 )||(ix >=accts .count ())) return null ;
647
651
return accts .get (ix );
@@ -725,11 +729,6 @@ public void validate() throws InvalidDataException {
725
729
super .validate ();
726
730
}
727
731
728
- @ Override
729
- public void validateCell () throws InvalidDataException {
730
- // nothing to do?
731
- }
732
-
733
732
/**
734
733
* Gets the current global timestamp from this state.
735
734
*
@@ -739,6 +738,11 @@ public CVMLong getTimestamp() {
739
738
return (CVMLong ) getGlobals ().get (GLOBAL_TIMESTAMP );
740
739
}
741
740
741
+ @ Override
742
+ public void validateCell () throws InvalidDataException {
743
+ // nothing to do?
744
+ }
745
+
742
746
/**
743
747
* Gets the current Juice price
744
748
*
@@ -960,4 +964,6 @@ protected State withValues(AVector<ACell> newValues) {
960
964
961
965
962
966
967
+
968
+
963
969
}
Original file line number Diff line number Diff line change 18
18
import convex .core .cvm .PeerStatus ;
19
19
import convex .core .cvm .State ;
20
20
import convex .core .data .AccountKey ;
21
+ import convex .core .data .Blob ;
22
+ import convex .core .data .Format ;
21
23
import convex .core .data .Hash ;
22
24
import convex .core .data .MapEntry ;
23
25
import convex .core .data .Ref ;
24
26
import convex .core .data .Refs ;
25
27
import convex .core .data .prim .CVMLong ;
28
+ import convex .core .exceptions .BadFormatException ;
26
29
import convex .core .exceptions .InvalidDataException ;
27
30
import convex .core .lang .ACVMTest ;
31
+ import convex .core .lang .Core ;
28
32
29
33
/**
30
34
* Tests for Init functionality
@@ -115,6 +119,16 @@ public void testMemoryExchange() {
115
119
assertEquals (Constants .INITIAL_MEMORY_POOL *Constants .INITIAL_MEMORY_PRICE ,cvx .longValue ());
116
120
}
117
121
122
+ @ Test
123
+ public void testInitEncoding () throws BadFormatException {
124
+ Blob b =Format .encodeMultiCell (STATE , true );
125
+
126
+ State s =Format .decodeMultiCell (b );
127
+ assertEquals (STATE ,s );
128
+ assertEquals (STATE .getAccount (Core .CORE_ADDRESS ),s .getAccount (Core .CORE_ADDRESS ));
129
+ assertEquals (STATE .getAccount (29 ),s .getAccount (29 ));
130
+ }
131
+
118
132
@ Test
119
133
public void testInitRef () {
120
134
State s =STATE ;
You can’t perform that action at this time.
0 commit comments