use of com.radixdlt.atomos.CMAtomOS in project radixdlt by radixdlt.
the class NextViewV2Test method setup.
@Before
public void setup() throws Exception {
var cmAtomOS = new CMAtomOS();
cmAtomOS.load(new SystemConstraintScrypt());
scrypts.forEach(cmAtomOS::load);
cmAtomOS.load(new StakingConstraintScryptV4(Amount.ofTokens(10).toSubunits()));
cmAtomOS.load(new TokensConstraintScryptV3(Set.of(), Pattern.compile("[a-z0-9]+")));
cmAtomOS.load(new ValidatorConstraintScryptV2());
cmAtomOS.load(new ValidatorRegisterConstraintScrypt());
cmAtomOS.load(new ValidatorUpdateRakeConstraintScrypt(2));
cmAtomOS.load(new ValidatorUpdateOwnerConstraintScrypt());
var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
var parser = new REParser(cmAtomOS.buildSubstateDeserialization());
var serialization = cmAtomOS.buildSubstateSerialization();
this.store = new InMemoryEngineStore<>();
this.sut = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(NextEpoch.class, new NextEpochConstructorV3(Amount.ofTokens(10).toSubunits(), 9800, 1, 10)).put(CreateSystem.class, new CreateSystemConstructorV2()).put(CreateMutableToken.class, new CreateMutableTokenConstructor(SystemConstraintScrypt.MAX_SYMBOL_LENGTH)).put(MintToken.class, new MintTokenConstructor()).put(StakeTokens.class, new StakeTokensConstructorV3(Amount.ofTokens(10).toSubunits())).put(NextRound.class, nextViewConstructor).put(RegisterValidator.class, new RegisterValidatorConstructor()).build(), cm, store);
this.key = ECKeyPair.generateNew();
var accountAddr = REAddr.ofPubKeyAccount(key.getPublicKey());
var txn = this.sut.construct(TxnConstructionRequest.create().action(new CreateSystem(0)).action(new CreateMutableToken(REAddr.ofNativeToken(), "xrd", "xrd", "", "", "", null)).action(new MintToken(REAddr.ofNativeToken(), accountAddr, Amount.ofTokens(10).toSubunits())).action(new StakeTokens(accountAddr, key.getPublicKey(), Amount.ofTokens(10).toSubunits())).action(new RegisterValidator(key.getPublicKey())).action(new NextEpoch(0))).buildWithoutSignature();
this.sut.execute(List.of(txn), null, PermissionLevel.SYSTEM);
}
use of com.radixdlt.atomos.CMAtomOS in project radixdlt by radixdlt.
the class CMTokensTest method setup.
@Before
public void setup() {
// Build the engine based on the constraint machine configured by the AtomOS
CMAtomOS cmAtomOS = new CMAtomOS();
cmAtomOS.load(new TokensConstraintScrypt());
this.cm = new ConstraintMachine.Builder().setParticleStaticCheck(cmAtomOS.buildParticleStaticCheck()).setParticleTransitionProcedures(cmAtomOS.buildTransitionProcedures()).build();
RadixAddress tokenAddress = new RadixAddress((byte) 0, ECKeyPair.generateNew().getPublicKey());
this.token = RRI.of(tokenAddress, "TEST");
this.granularity = UInt256.ONE;
this.permissions = ImmutableMap.of(TokenTransition.BURN, TokenPermission.TOKEN_OWNER_ONLY, TokenTransition.MINT, TokenPermission.TOKEN_OWNER_ONLY);
}
use of com.radixdlt.atomos.CMAtomOS in project radixdlt by radixdlt.
the class FixedFeeTest method setup.
@Before
public void setup() throws Exception {
var cmAtomOS = new CMAtomOS();
cmAtomOS.load(new TokensConstraintScryptV3(Set.of(), Pattern.compile("[a-z0-9]+")));
cmAtomOS.load(new SystemConstraintScrypt());
var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization(), FixedFeeMeter.create(UInt256.FIVE));
var parser = new REParser(cmAtomOS.buildSubstateDeserialization());
var serialization = cmAtomOS.buildSubstateSerialization();
this.store = new InMemoryEngineStore<>();
this.engine = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(CreateSystem.class, new CreateSystemConstructorV2()).put(TransferToken.class, new TransferTokensConstructorV2()).put(CreateMutableToken.class, new CreateMutableTokenConstructor(SystemConstraintScrypt.MAX_SYMBOL_LENGTH)).put(MintToken.class, new MintTokenConstructor()).put(FeeReservePut.class, new FeeReservePutConstructor()).put(FeeReserveTake.class, new FeeReserveTakeConstructor()).build(), cm, store);
var txn = this.engine.construct(TxnConstructionRequest.create().action(new CreateSystem(0)).action(new CreateMutableToken(REAddr.ofNativeToken(), "xrd", "xrd", "", "", "", null)).action(new MintToken(REAddr.ofNativeToken(), accountAddr, UInt256.TEN))).buildWithoutSignature();
this.engine.execute(List.of(txn), null, PermissionLevel.SYSTEM);
}
use of com.radixdlt.atomos.CMAtomOS in project radixdlt by radixdlt.
the class NextEpochV2Test method setup.
@Before
public void setup() {
var cmAtomOS = new CMAtomOS();
cmAtomOS.load(new SystemConstraintScrypt());
scrypts.forEach(cmAtomOS::load);
// For v1 start
cmAtomOS.load(new MutexConstraintScrypt());
var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
this.parser = new REParser(cmAtomOS.buildSubstateDeserialization());
var serialization = cmAtomOS.buildSubstateSerialization();
this.store = new InMemoryEngineStore<>();
this.sut = new RadixEngine<>(parser, serialization, constructors, cm, store);
}
use of com.radixdlt.atomos.CMAtomOS in project radixdlt by radixdlt.
the class DelegationFlagTest method setup.
@Before
public void setup() throws Exception {
var cmAtomOS = new CMAtomOS();
cmAtomOS.load(new SystemConstraintScrypt());
scrypts.forEach(cmAtomOS::load);
var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
var parser = new REParser(cmAtomOS.buildSubstateDeserialization());
var serialization = cmAtomOS.buildSubstateSerialization();
this.store = new InMemoryEngineStore<>();
this.engine = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(StakeTokens.class, stakeTokensConstructor).put(CreateMutableToken.class, new CreateMutableTokenConstructor(SystemConstraintScrypt.MAX_SYMBOL_LENGTH)).put(MintToken.class, new MintTokenConstructor()).put(UpdateAllowDelegationFlag.class, new UpdateAllowDelegationFlagConstructor()).put(UpdateValidatorOwner.class, new UpdateValidatorOwnerConstructor()).put(CreateSystem.class, new CreateSystemConstructorV2()).build(), cm, store);
var txn = this.engine.construct(new CreateSystem(0)).buildWithoutSignature();
this.engine.execute(List.of(txn), null, PermissionLevel.SYSTEM);
}
Aggregations