Skip to content

Commit 93bfae1

Browse files
committed
test(contract): ensure asset exists when adding a label
1 parent 0645530 commit 93bfae1

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

projects/asset_labeling-contracts/tests/asset-labeling.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,4 +699,42 @@ describe('asset labeling contract', () => {
699699

700700
await expect(() => removeLabelFromAsset(operatorClient, assetId, label2)).rejects.toThrow(/ERR:NOEXIST/)
701701
})
702+
703+
test('add label to deleted asset should fail', async () => {
704+
const { testAccount: adminAccount, algorand } = localnet.context
705+
706+
const {assetId} = await algorand.send.assetCreate({
707+
sender: adminAccount.addr,
708+
total: 1000000n, // Total units of the asset
709+
decimals: 0, // Number of decimals for the asset
710+
defaultFrozen: false, // Whether the asset is frozen by default
711+
manager: adminAccount.addr, // Address for the asset manager
712+
reserve: adminAccount.addr, // Address for storing reserve assets
713+
freeze: adminAccount.addr, // Address with freezing capabilities
714+
clawback: adminAccount.addr, // Address with clawback rights
715+
unitName: 'UNIT', // Unit name of the asset
716+
assetName: 'TestAsset', // Asset name
717+
})
718+
await algorand.send.assetDestroy({
719+
sender: adminAccount.addr,
720+
assetId
721+
})
722+
723+
724+
const { adminClient } = await deploy(adminAccount)
725+
const label = 'wo'
726+
const labelName = 'world'
727+
const labelUrl = 'http://'
728+
729+
730+
await addLabel(adminClient, adminAccount, label, labelName, labelUrl)
731+
const operator = await localnet.context.generateAccount({ initialFunds: (0.2).algos() })
732+
await addOperatorToLabel(adminClient, operator, label)
733+
const operatorClient = adminClient.clone({
734+
defaultSender: operator,
735+
defaultSigner: operator.signer,
736+
})
737+
// This should throw
738+
await expect(()=>addLabelToAsset(operatorClient, assetId, label)).rejects.toThrow(/ERR:NOEXIST/)
739+
})
702740
})

projects/asset_labeling-contracts/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
"noEmit": true
2222
},
2323
"include": ["smart_contracts/**/*.ts"],
24-
"exclude": ["node_modules", "dist", "coverage"]
24+
"exclude": ["node_modules", "dist", "coverage"],
25+
"references": [{"path": "./tsconfig.test.json"}]
2526
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"include": ["tests/**/*.ts", "smart_contracts/artifacts/**/*.ts"]
7+
}

0 commit comments

Comments
 (0)