Skip to content

Commit

Permalink
Issue #27 refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
radicleart committed Dec 12, 2022
1 parent 2b43e56 commit 5d0e338
Show file tree
Hide file tree
Showing 28 changed files with 127 additions and 111 deletions.
84 changes: 42 additions & 42 deletions Clarinet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,68 +47,68 @@ path = "contracts/extensions/ccd006-city-mining.clar"
[contracts.ccd007-city-stacking]
path = "contracts/extensions/ccd007-city-stacking.clar"

[contracts.ccext-governance-token-mia]
path = "contracts/external/ccext-governance-token-mia.clar"
[contracts.test-ccext-governance-token-mia]
path = "tests/contracts/external/test-ccext-governance-token-mia.clar"

[contracts.ccext-governance-token-nyc]
path = "contracts/external/ccext-governance-token-nyc.clar"
[contracts.test-ccext-governance-token-nyc]
path = "tests/contracts/external/test-ccext-governance-token-nyc.clar"

[contracts.ccext-nft-mia]
path = "contracts/external/ccext-nft-mia.clar"
[contracts.test-ccext-nft-mia]
path = "tests/contracts/external/test-ccext-nft-mia.clar"

[contracts.ccext-nft-nyc]
path = "contracts/external/ccext-nft-nyc.clar"
[contracts.test-ccext-nft-nyc]
path = "tests/contracts/external/test-ccext-nft-nyc.clar"

[contracts.ccip-test-direct-execute-001]
path = "contracts/proposals/ccip-test-direct-execute-001.clar"
[contracts.test-ccd001-direct-execute-001]
path = "tests/contracts/proposals/test-ccd001-direct-execute-001.clar"

[contracts.ccip-test-direct-execute-002]
path = "contracts/proposals/ccip-test-direct-execute-002.clar"
[contracts.test-ccd001-direct-execute-002]
path = "tests/contracts/proposals/test-ccd001-direct-execute-002.clar"

[contracts.ccip-test-direct-execute-003]
path = "contracts/proposals/ccip-test-direct-execute-003.clar"
[contracts.test-ccd001-direct-execute-003]
path = "tests/contracts/proposals/test-ccd001-direct-execute-003.clar"

[contracts.ccip-test-treasury-001]
path = "contracts/proposals/ccip-test-treasury-001.clar"
[contracts.test-ccd002-treasury-001]
path = "tests/contracts/proposals/test-ccd002-treasury-001.clar"

[contracts.ccip-test-treasury-002]
path = "contracts/proposals/ccip-test-treasury-002.clar"
[contracts.test-ccd002-treasury-002]
path = "tests/contracts/proposals/test-ccd002-treasury-002.clar"

[contracts.ccip-test-treasury-003]
path = "contracts/proposals/ccip-test-treasury-003.clar"
[contracts.test-ccd002-treasury-003]
path = "tests/contracts/proposals/test-ccd002-treasury-003.clar"

[contracts.ccip-test-treasury-004]
path = "contracts/proposals/ccip-test-treasury-004.clar"
[contracts.test-ccd002-treasury-004]
path = "tests/contracts/proposals/test-ccd002-treasury-004.clar"

[contracts.ccip-test-treasury-005]
path = "contracts/proposals/ccip-test-treasury-005.clar"
[contracts.test-ccd002-treasury-005]
path = "tests/contracts/proposals/test-ccd002-treasury-005.clar"

[contracts.ccip-test-treasury-006]
path = "contracts/proposals/ccip-test-treasury-006.clar"
[contracts.test-ccd002-treasury-006]
path = "tests/contracts/proposals/test-ccd002-treasury-006.clar"

[contracts.ccip-test-treasury-007]
path = "contracts/proposals/ccip-test-treasury-007.clar"
[contracts.test-ccd002-treasury-007]
path = "tests/contracts/proposals/test-ccd002-treasury-007.clar"

[contracts.ccip-test-treasury-008]
path = "contracts/proposals/ccip-test-treasury-008.clar"
[contracts.test-ccd002-treasury-008]
path = "tests/contracts/proposals/test-ccd002-treasury-008.clar"

[contracts.ccip-test-treasury-009]
path = "contracts/proposals/ccip-test-treasury-009.clar"
[contracts.test-ccd002-treasury-009]
path = "tests/contracts/proposals/test-ccd002-treasury-009.clar"

[contracts.ccip-test-treasury-010]
path = "contracts/proposals/ccip-test-treasury-010.clar"
[contracts.test-ccd002-treasury-010]
path = "tests/contracts/proposals/test-ccd002-treasury-010.clar"

[contracts.ccip-test-user-registry-001]
path = "contracts/proposals/ccip-test-user-registry-001.clar"
[contracts.test-ccd003-user-registry-001]
path = "tests/contracts/proposals/test-ccd003-user-registry-001.clar"

[contracts.ccip-test-user-registry-002]
path = "contracts/proposals/ccip-test-user-registry-002.clar"
[contracts.test-ccd003-user-registry-002]
path = "tests/contracts/proposals/test-ccd003-user-registry-002.clar"

[contracts.ccip-test-user-registry-003]
path = "contracts/proposals/ccip-test-user-registry-003.clar"
[contracts.test-ccd003-user-registry-003]
path = "tests/contracts/proposals/test-ccd003-user-registry-003.clar"

[contracts.ccip-test-city-registry-001]
path = "contracts/proposals/ccip-test-city-registry-001.clar"
[contracts.test-ccd004-city-registry-001]
path = "tests/contracts/proposals/test-ccd004-city-registry-001.clar"

[contracts.ccip012-bootstrap]
path = "contracts/proposals/ccip012-bootstrap.clar"
Expand Down
23 changes: 0 additions & 23 deletions contracts/proposals/ccip-test-treasury-004.clar

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(define-public (execute (sender principal))
(begin
;; tests success of setting sunset height
(try! (contract-call? .ccd002-treasury-mia set-allowed 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-governance-token-mia true))
(try! (contract-call? .ccd002-treasury-mia set-allowed 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-governance-token-mia true))
(ok true)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
;; tests success of setting sunset height
(try! (contract-call? .ccd002-treasury-mia set-allowed-list
(list
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-governance-token-mia, enabled: true}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-governance-token-nyc, enabled: false}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-nft-nyc, enabled: false}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-governance-token-mia, enabled: true}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-governance-token-nyc, enabled: false}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-nft-nyc, enabled: false}
)
))
(ok true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
;; tests success of setting sunset height
(try! (contract-call? .ccd002-treasury-mia set-allowed-list
(list
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-governance-token-mia, enabled: false}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-governance-token-nyc, enabled: true}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-governance-token-mia, enabled: false}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-governance-token-nyc, enabled: true}
)
))
(ok true)
Expand Down
23 changes: 23 additions & 0 deletions tests/contracts/proposals/test-ccd002-treasury-004.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
;; Title: Test Proposal
;; Version: 1.0.0
;; Synopsis: Test proposal for clarinet layer
;; Description:
;; ccd002-treasury: deposit-ft() succeeds and transfers FT to the vault

(impl-trait .proposal-trait.proposal-trait)

(define-public (execute (sender principal))
(begin
;; mint type 01 tokens to wallets 5,6,7,8 for testing
(try! (contract-call? .test-ccext-governance-token-mia edg-mint u2000 'ST2REHHS5J3CERCRBEPMGH7921Q6PYKAADT7JP2VB))
(try! (contract-call? .test-ccext-governance-token-mia edg-mint u2000 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(try! (contract-call? .test-ccext-governance-token-mia edg-mint u2000 'ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ))
(try! (contract-call? .test-ccext-governance-token-mia edg-mint u2000 'ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP))
;; mint type 02 tokens to wallets 5,6,7,8 for testing
(try! (contract-call? .test-ccext-governance-token-nyc edg-mint u2000 'ST2REHHS5J3CERCRBEPMGH7921Q6PYKAADT7JP2VB))
(try! (contract-call? .test-ccext-governance-token-nyc edg-mint u2000 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(try! (contract-call? .test-ccext-governance-token-nyc edg-mint u2000 'ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ))
(try! (contract-call? .test-ccext-governance-token-nyc edg-mint u2000 'ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP))
(ok true)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
;; tests success of setting sunset height
(try! (contract-call? .ccd002-treasury-nyc set-allowed-list
(list
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-nft-mia, enabled: true}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-nft-nyc, enabled: true}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-nft-mia, enabled: true}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-nft-nyc, enabled: true}
)
))
(ok true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(define-public (execute (sender principal))
(begin
;; tests success of setting sunset height
(try! (contract-call? .ccd002-treasury-nyc withdraw-ft .ccext-governance-token-nyc u500 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(try! (contract-call? .ccd002-treasury-nyc withdraw-ft .test-ccext-governance-token-nyc u500 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(ok true)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
;; tests success of setting sunset height
(try! (contract-call? .ccd002-treasury-mia set-allowed-list
(list
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-governance-token-mia, enabled: true}
{token: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-governance-token-mia, enabled: true}
)
))
(try! (contract-call? .ccext-governance-token-mia edg-mint u2000 .ccd002-treasury-mia))
(try! (contract-call? .ccd002-treasury-mia withdraw-ft .ccext-governance-token-mia u500 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(try! (contract-call? .test-ccext-governance-token-mia edg-mint u2000 .ccd002-treasury-mia))
(try! (contract-call? .ccd002-treasury-mia withdraw-ft .test-ccext-governance-token-mia u500 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(ok true)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(define-public (execute (sender principal))
(begin
;; tests success of setting sunset height
(try! (contract-call? .ccd002-treasury-nyc withdraw-nft 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-nft-nyc u1 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(try! (contract-call? .ccd002-treasury-nyc withdraw-nft 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-nft-nyc u1 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(ok true)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(define-public (execute (sender principal))
(begin
;; tests success of setting sunset height
(try! (contract-call? .ccd002-treasury-mia withdraw-ft .ccext-governance-token-mia u2000 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(try! (contract-call? .ccd002-treasury-mia withdraw-ft .test-ccext-governance-token-mia u2000 'ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0))
(ok true)
)
)
16 changes: 16 additions & 0 deletions tests/contracts/proposals/test-ccd005-city-data-001.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;; Title: Test Proposal
;; Version: 1.0.0
;; Synopsis: Test proposal for clarinet layer
;; Description:
;; ccd004-city-registry: get-or-create-city-id() increments the user id nonce
;; ccd004-city-registry: get-or-create-city-id() increments the user id nonce

(impl-trait .proposal-trait.proposal-trait)

(define-public (execute (sender principal))
(begin
(try! (contract-call? .ccd005-city-data get-or-create-city-id "mia"))
(try! (contract-call? .ccd005-city-data get-or-create-city-id "nyc"))
(ok true)
)
)
22 changes: 11 additions & 11 deletions tests/extensions/ccd002-treasury.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
} from "../../utils/common.ts";
import { PROPOSALS } from "../../utils/common.ts";
import { CCD002Treasury } from "../../models/extensions/ccd002-treasury.model.ts";
import { CCEXTGovernanceToken } from "../../models/external/ccext-governance-token.model.ts";
import { CCEXTNft } from "../../models/external/ccext-nft.model.ts";
import { CCEXTGovernanceToken } from "../../models/external/test-ccext-governance-token.model.ts";
import { CCEXTNft } from "../../models/external/test-ccext-nft.model.ts";

// Authorization check

Expand Down Expand Up @@ -318,7 +318,7 @@ Clarinet.test({
const gt = new CCEXTGovernanceToken(
chain,
sender,
"ccext-governance-token-mia"
"test-ccext-governance-token-mia"
);
const amount = 1000;
constructAndPassProposal(
Expand All @@ -331,7 +331,7 @@ Clarinet.test({
passProposal(chain, accounts, PROPOSALS.TEST_CCD002_TREASURY_004);
gt.getBalance(depositor.address).result.expectOk().expectUint(2000);
const event =
'{amount: u1000, assetContract: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccext-governance-token-mia, caller: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0, event: "deposit-ft", recipient: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccd002-treasury-mia, sender: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0}';
'{amount: u1000, assetContract: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccext-governance-token-mia, caller: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0, event: "deposit-ft", recipient: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccd002-treasury-mia, sender: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0}';

// act
const { receipts } = chain.mineBlock([
Expand Down Expand Up @@ -397,7 +397,7 @@ Clarinet.test({
sender,
"ccd002-treasury-nyc"
);
const nft = new CCEXTNft(chain, sender, "ccext-nft-nyc");
const nft = new CCEXTNft(chain, sender, "test-ccext-nft-nyc");
const tokenId = 1;
// Enable NYC NFT asset contract
constructAndPassProposal(
Expand Down Expand Up @@ -484,7 +484,7 @@ Clarinet.test({
chain.mineBlock([ccd002Treasury.depositStx(sender, amount1)]);
ccd002Treasury.getBalanceStx().result.expectUint(amount1);
const event =
'{amount: u500, caller: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccip-test-treasury-006, event: "withdraw-stx", recipient: ' +
'{amount: u500, caller: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccd002-treasury-006, event: "withdraw-stx", recipient: ' +
recipient.address +
", sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.base-dao}";

Expand Down Expand Up @@ -587,7 +587,7 @@ Clarinet.test({
const gt = new CCEXTGovernanceToken(
chain,
sender,
"ccext-governance-token-mia"
"test-ccext-governance-token-mia"
);
gt.getBalance(recipient.address).result.expectOk().expectUint(0);
gt.getBalance(EXTENSIONS.CCD002_TREASURY_MIA)
Expand Down Expand Up @@ -640,7 +640,7 @@ Clarinet.test({
const gt = new CCEXTGovernanceToken(
chain,
sender,
"ccext-governance-token-mia"
"test-ccext-governance-token-mia"
);
gt.getBalance(recipient.address).result.expectOk().expectUint(0);
gt.getBalance(EXTENSIONS.CCD002_TREASURY_MIA)
Expand Down Expand Up @@ -715,7 +715,7 @@ Clarinet.test({
);
ccd002Treasury.isAllowed(EXTERNAL.NFT_NYC).result.expectBool(false);
const tokenId = 1;
const nft = new CCEXTNft(chain, sender, "ccext-nft-nyc");
const nft = new CCEXTNft(chain, sender, "test-ccext-nft-nyc");
// mint an asset to the treasury
chain.mineBlock([nft.mint(EXTENSIONS.CCD002_TREASURY_NYC, sender.address)]);
// Check asset is owned by the nyc treasury
Expand Down Expand Up @@ -758,7 +758,7 @@ Clarinet.test({
"ccd002-treasury-nyc"
);
const recipient = accounts.get("wallet_6")!;
const nft = new CCEXTNft(chain, sender, "ccext-nft-nyc");
const nft = new CCEXTNft(chain, sender, "test-ccext-nft-nyc");
const tokenId = 1;
// Proposal 5 allow lists NYC NFT asset contract
constructAndPassProposal(
Expand All @@ -777,7 +777,7 @@ Clarinet.test({
const event =
"{assetContract: " +
EXTERNAL.NFT_NYC +
', caller: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.ccip-test-treasury-009, event: "withdraw-nft", recipient: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0, sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.base-dao, tokenId: u1}';
', caller: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-ccd002-treasury-009, event: "withdraw-nft", recipient: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0, sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.base-dao, tokenId: u1}';

// act
// proposal 9 transfers the nft from the treasury to recipient
Expand Down
Loading

0 comments on commit 5d0e338

Please sign in to comment.