|
1 | 1 | import { arc4, Bytes } from '@algorandfoundation/algorand-typescript' |
2 | 2 | import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing' |
3 | | -import { interpretAsArc4 } from '@algorandfoundation/algorand-typescript/arc4' |
| 3 | +import { convertBytes } from '@algorandfoundation/algorand-typescript/arc4' |
4 | 4 | import { afterEach, describe, expect, test } from 'vitest' |
5 | 5 | import DigitalMarketplace, { ListingKey, ListingValue } from './contract.algo' |
6 | 6 |
|
@@ -39,7 +39,9 @@ describe('DigitalMarketplace', () => { |
39 | 39 | asset: new arc4.Uint64(testAsset.id), |
40 | 40 | nonce: testNonce, |
41 | 41 | }) |
42 | | - const listingValue = interpretAsArc4<ListingValue>(Bytes(ctx.ledger.getBox(contract, Bytes('listings').concat(listingKey.bytes)))) |
| 42 | + const listingValue = convertBytes<ListingValue>(Bytes(ctx.ledger.getBox(contract, Bytes('listings').concat(listingKey.bytes))), { |
| 43 | + strategy: 'unsafe-cast', |
| 44 | + }) |
43 | 45 | expect(listingValue.deposited.asUint64()).toEqual(10) |
44 | 46 | }) |
45 | 47 |
|
@@ -100,7 +102,9 @@ describe('DigitalMarketplace', () => { |
100 | 102 | contract.setPrice(testAsset, testNonce, testUnitaryPrice) |
101 | 103 |
|
102 | 104 | // Assert |
103 | | - const updatedListing = interpretAsArc4<ListingValue>(Bytes(ctx.ledger.getBox(contract, Bytes('listings').concat(listingKey.bytes)))) |
| 105 | + const updatedListing = convertBytes<ListingValue>(Bytes(ctx.ledger.getBox(contract, Bytes('listings').concat(listingKey.bytes))), { |
| 106 | + strategy: 'unsafe-cast', |
| 107 | + }) |
104 | 108 | expect(updatedListing.unitaryPrice.asUint64()).toEqual(testUnitaryPrice.asUint64()) |
105 | 109 | }) |
106 | 110 |
|
@@ -136,7 +140,9 @@ describe('DigitalMarketplace', () => { |
136 | 140 | ) |
137 | 141 |
|
138 | 142 | // Assert |
139 | | - const updatedListing = interpretAsArc4<ListingValue>(Bytes(ctx.ledger.getBox(contract, Bytes('listings').concat(listingKey.bytes)))) |
| 143 | + const updatedListing = convertBytes<ListingValue>(Bytes(ctx.ledger.getBox(contract, Bytes('listings').concat(listingKey.bytes))), { |
| 144 | + strategy: 'unsafe-cast', |
| 145 | + }) |
140 | 146 | expect(updatedListing.deposited.asUint64()).toEqual(initialDeposit.asUint64() - testBuyQuantity.asUint64()) |
141 | 147 | expect(ctx.txn.lastGroup.getItxnGroup(0).getAssetTransferInnerTxn(0).assetReceiver).toEqual(ctx.defaultSender) |
142 | 148 | }) |
|
0 commit comments