use of org.tron.core.capsule.AccountCapsule in project java-tron by tronprotocol.
the class AccountStore method getSun.
/**
* Max TRX account.
*/
public AccountCapsule getSun() {
byte[] data = dbSource.getData(ByteString.copyFrom(ByteArray.fromHexString(ACCOUNT_SUN_ADDRESS)).toByteArray());
AccountCapsule accountCapsule = new AccountCapsule(data);
return accountCapsule;
}
use of org.tron.core.capsule.AccountCapsule in project java-tron by tronprotocol.
the class AssetIssueActuatorTest method rightAssetIssue.
@Test
public void rightAssetIssue() {
AssetIssueActuator actuator = new AssetIssueActuator(getContract(), dbManager);
TransactionResultCapsule ret = new TransactionResultCapsule();
try {
actuator.validate();
actuator.execute(ret);
Assert.assertEquals(ret.getInstance().getRet(), code.SUCESS);
AccountCapsule owner = dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS));
AssetIssueCapsule assetIssueCapsule = dbManager.getAssetIssueStore().get(ByteString.copyFromUtf8(NAME).toByteArray());
Assert.assertNotNull(assetIssueCapsule);
Assert.assertEquals(owner.getBalance(), 0L);
Assert.assertEquals(owner.getAssetMap().get(NAME).longValue(), 10000L);
} catch (ContractValidateException e) {
Assert.assertFalse(e instanceof ContractValidateException);
} catch (ContractExeException e) {
Assert.assertFalse(e instanceof ContractExeException);
} finally {
dbManager.getAssetIssueStore().delete(ByteArray.fromString(NAME));
}
}
use of org.tron.core.capsule.AccountCapsule in project java-tron by tronprotocol.
the class AssetIssueActuatorTest method repeatAssetIssue.
@Test
public void repeatAssetIssue() {
AssetIssueActuator actuator = new AssetIssueActuator(getContract(), dbManager);
TransactionResultCapsule ret = new TransactionResultCapsule();
try {
dbManager.getAssetIssueStore().put(ByteArray.fromString(NAME), new AssetIssueCapsule(getContract().unpack(Contract.AssetIssueContract.class)));
actuator.validate();
actuator.execute(ret);
Assert.assertTrue(false);
} catch (ContractValidateException e) {
Assert.assertTrue(e instanceof ContractValidateException);
AccountCapsule owner = dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS));
AssetIssueCapsule assetIssueCapsule = dbManager.getAssetIssueStore().get(ByteArray.fromString(NAME));
Assert.assertNotNull(assetIssueCapsule);
Assert.assertNull(owner.getInstance().getAssetMap().get(NAME));
} catch (ContractExeException e) {
Assert.assertFalse(e instanceof ContractExeException);
} catch (InvalidProtocolBufferException e) {
Assert.assertFalse(e instanceof InvalidProtocolBufferException);
} finally {
dbManager.getAssetIssueStore().delete(ByteArray.fromString(NAME));
}
}
use of org.tron.core.capsule.AccountCapsule in project java-tron by tronprotocol.
the class CreateAccountActuatorTest method createCapsule.
/**
* create temp Capsule test need.
*/
@Before
public void createCapsule() {
AccountCapsule ownerCapsule = new AccountCapsule(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS_SECOND)), ByteString.copyFromUtf8(ACCOUNT_NAME_SECOND), AccountType.AssetIssue);
dbManager.getAccountStore().put(ownerCapsule.getAddress().toByteArray(), ownerCapsule);
dbManager.getAccountStore().delete(ByteArray.fromHexString(OWNER_ADDRESS_FRIST));
}
use of org.tron.core.capsule.AccountCapsule in project java-tron by tronprotocol.
the class CreateAccountActuatorTest method firstCreateAccount.
/**
* Unit test.
*/
@Test
public void firstCreateAccount() {
CreateAccountActuator actuator = new CreateAccountActuator(getContract(ACCOUNT_NAME_FRIST, OWNER_ADDRESS_FRIST), dbManager);
TransactionResultCapsule ret = new TransactionResultCapsule();
try {
actuator.validate();
actuator.execute(ret);
Assert.assertEquals(ret.getInstance().getRet(), code.SUCESS);
AccountCapsule accountCapsule = dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS_FRIST));
Assert.assertNotNull(accountCapsule);
Assert.assertEquals(accountCapsule.getInstance().getAccountName(), ByteString.copyFromUtf8(ACCOUNT_NAME_FRIST));
} catch (ContractValidateException e) {
Assert.assertFalse(e instanceof ContractValidateException);
} catch (ContractExeException e) {
Assert.assertFalse(e instanceof ContractExeException);
}
}
Aggregations