Skip to content

Commit

Permalink
fix unittest after use current block time stamp as current time.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohong committed May 9, 2018
1 parent 8ad6628 commit 4c900ad
Showing 1 changed file with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ private void initAssetIssueWithOwner(long startTimestmp, long endTimestmp, Strin
@Test
public void rightAssetIssue() {
DateTime now = DateTime.now();
initAssetIssue(now.minusDays(1).getMillis(), now.plusDays(1).getMillis());
initAssetIssue(dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() - 1000,
dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() + 1000);
ParticipateAssetIssueActuator actuator =
new ParticipateAssetIssueActuator(getContract(1000L), dbManager);
TransactionResultCapsule ret = new TransactionResultCapsule();
Expand Down Expand Up @@ -287,7 +288,8 @@ public void AssetIssueTimeLeft() {
@Test
public void ExchangeDevisibleTest() {
DateTime now = DateTime.now();
initAssetIssue(now.minusDays(1).getMillis(), now.plusDays(1).getMillis());
initAssetIssue(dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() - 1000,
dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() + 1000);
ParticipateAssetIssueActuator actuator =
new ParticipateAssetIssueActuator(getContract(999L), dbManager); //no problem
TransactionResultCapsule ret = new TransactionResultCapsule();
Expand Down Expand Up @@ -377,7 +379,8 @@ public void zeroAmountTest() {
public void noExitOwnerTest() {
DateTime now = DateTime.now();
initAssetIssue(now.minusDays(1).getMillis(), now.plusDays(1).getMillis());
ParticipateAssetIssueActuator actuator = new ParticipateAssetIssueActuator(getContractWithOwner(101, NOT_EXIT_ADDRESS),
ParticipateAssetIssueActuator actuator = new ParticipateAssetIssueActuator(
getContractWithOwner(101, NOT_EXIT_ADDRESS),
dbManager);
TransactionResultCapsule ret = new TransactionResultCapsule();
try {
Expand Down Expand Up @@ -408,8 +411,12 @@ public void noExitOwnerTest() {
*/
public void noExitToTest() {
DateTime now = DateTime.now();
initAssetIssueWithOwner(now.minusDays(1).getMillis(), now.plusDays(1).getMillis(), NOT_EXIT_ADDRESS);
ParticipateAssetIssueActuator actuator = new ParticipateAssetIssueActuator(getContractWithTo(101, NOT_EXIT_ADDRESS),
initAssetIssueWithOwner(
dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() - 1000,
dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() + 1000,
NOT_EXIT_ADDRESS);
ParticipateAssetIssueActuator actuator = new ParticipateAssetIssueActuator(
getContractWithTo(101, NOT_EXIT_ADDRESS),
dbManager);
TransactionResultCapsule ret = new TransactionResultCapsule();
try {
Expand Down Expand Up @@ -437,7 +444,8 @@ public void noExitToTest() {
@Test
public void notEnoughTrxTest() {
DateTime now = DateTime.now();
initAssetIssue(now.minusDays(1).getMillis(), now.plusDays(1).getMillis());
initAssetIssue(dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() - 1000,
dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() + 1000);
// First, reduce the owner trx balance. Else can't complete this test case.
AccountCapsule owner = dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS));
owner.setBalance(100);
Expand Down Expand Up @@ -470,7 +478,8 @@ public void notEnoughTrxTest() {
@Test
public void notEnoughAssetTest() {
DateTime now = DateTime.now();
initAssetIssue(now.minusDays(1).getMillis(), now.plusDays(1).getMillis());
initAssetIssue(dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() - 1000,
dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() + 1000);
// First, reduce to account asset balance. Else can't complete this test case.
AccountCapsule toAccount = dbManager.getAccountStore().get(ByteArray.fromHexString(TO_ADDRESS));
toAccount.reduceAssetAmount(ByteString.copyFromUtf8(ASSET_NAME), TOTAL_SUPPLY - 10000);
Expand Down Expand Up @@ -533,7 +542,8 @@ public void noneExistAssetTest() {
@Test
public void addOverflowTest() {
DateTime now = DateTime.now();
initAssetIssue(now.minusDays(1).getMillis(), now.plusDays(1).getMillis());
initAssetIssue(dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() - 1000,
dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() + 1000);
// First, increase the owner asset balance. Else can't complete this test case.
AccountCapsule owner = dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS));
owner.addAsset(ASSET_NAME, Long.MAX_VALUE);
Expand Down Expand Up @@ -569,7 +579,8 @@ public void addOverflowTest() {
@Test
public void mmultiplyOverflowTest() {
DateTime now = DateTime.now();
initAssetIssue(now.minusDays(1).getMillis(), now.plusDays(1).getMillis());
initAssetIssue(dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() - 1000,
dbManager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp() + 1000);
// First, increase the owner trx balance. Else can't complete this test case.
AccountCapsule owner = dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS));
owner.setBalance(100000000000000L);
Expand Down

0 comments on commit 4c900ad

Please sign in to comment.