Skip to content

Commit

Permalink
More market trade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Aug 14, 2023
1 parent a4aabe0 commit 906dd9b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions convex-core/src/test/java/convex/lib/MarketTradeTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package convex.lib;

import static convex.test.Assertions.assertFundsError;
import static convex.test.Assertions.assertNotError;
import static convex.test.Assertions.assertStateError;
import static convex.test.Assertions.assertTrustError;
import static convex.test.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down Expand Up @@ -61,12 +58,20 @@ public class MarketTradeTest extends ACVMTest {
// Nobody else should be able to cancel
assertTrustError(step(ctx.forkWithAddress(Address.ZERO),"(do (import asset.market.trade :as t) (t/cancel "+tid+"))"));

// Cancel trade
// Cancel trade - should succeed
ctx=step(ctx,"(trade/cancel tid)");
assertNotError(ctx);
assertNotError(ctx);

// Check that asset is returned and no tokens spent
assertEquals(BAL,evalL(ctx,"(asset/balance wcvx)"));
assertTrue(evalB(ctx,"(asset/owns? *address* item)"));

// Can't cancel a second time, should be already gone
assertStateError(step(ctx,"(trade/cancel tid)"));

// Can't cancel a non-existent trade
assertStateError(step(ctx,"(trade/cancel 696969)"));

}


Expand All @@ -86,6 +91,9 @@ public class MarketTradeTest extends ACVMTest {
CVMLong tid=ctx.getResult();
assertNotNull(tid);

// Can't post something not owned, since we already posted for sale
assertError(step(ctx,"(def tid (trade/post item [wcvx 1]))"));

// No coins spent yet!
assertEquals(BAL,evalL(ctx,"(asset/balance wcvx)"));

Expand Down

0 comments on commit 906dd9b

Please sign in to comment.