Skip to content

Commit

Permalink
extra Belief tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Jul 11, 2023
1 parent 8058905 commit 0234978
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions convex-core/src/test/java/convex/core/BeliefTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package convex.core;

import org.junit.jupiter.api.Test;

import convex.core.crypto.AKeyPair;
import convex.core.data.ACell;
import convex.core.data.AccountKey;
import convex.core.data.Address;
import convex.core.data.EncodingTest;
import convex.core.data.RecordTest;
import convex.core.data.SignedData;
import convex.core.exceptions.BadFormatException;
import convex.core.transactions.Invoke;
import convex.test.Samples;

public class BeliefTest {
static final int PEERS=4;
static final AKeyPair[] kps=new AKeyPair[PEERS];
static final AccountKey[] keys=new AccountKey[PEERS];

static {
for (int i=0; i<PEERS; i++) {
AKeyPair kp=AKeyPair.createSeeded(i+789798);
kps[i]=kp;
keys[i]=kp.getAccountKey();
}
}

@SuppressWarnings("unchecked")
@Test public void testBasicBelief() throws BadFormatException {
Order o=Order.create();
for (int i=0; i<PEERS; i++) {
AKeyPair kp=kps[i];
Block bi=Block.of(i, kp.signData(Invoke.create(Address.create(i), 1L, Samples.NON_EMBEDDED_STRING)));
o=o.append(kp.signData(bi));
}
SignedData<Order>[] orders=new SignedData[PEERS];
for (int i=0; i<PEERS; i++) {
AKeyPair kp=kps[i];
orders[i]=kp.signData(o);
}
Belief b=Belief.create(orders);

RecordTest.doRecordTests(b);

b=ACell.createPersisted(b).getValue();

RecordTest.doRecordTests(b);

EncodingTest.testFullencoding(b);
}
}

0 comments on commit 0234978

Please sign in to comment.