Skip to content

Commit b97e299

Browse files
committed
fix: progress chain before at-block
Haven't narrowed down the exact bug but can continue making the generalized proposal functions now that flow is confirmed.
1 parent 85cfe9d commit b97e299

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

tests/dao/extensions/aibtc-onchain-messaging.test.ts

+22-15
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import {
77
} from "../../test-utilities";
88

99
const accounts = simnet.getAccounts();
10-
const address1 = accounts.get("wallet_1")!;
1110
const deployer = accounts.get("deployer")!;
11+
const address1 = accounts.get("wallet_1")!;
12+
const address2 = accounts.get("wallet_2")!;
1213

1314
const contractName = "aibtc-onchain-messaging";
1415
const contractAddress = `${deployer}.${contractName}`;
@@ -57,20 +58,31 @@ describe(`extension: ${contractName}`, () => {
5758
const message = "test";
5859

5960
// fund account that sends proposal
60-
const getDaoTokensReceipt = getDaoTokens(deployer, deployer);
61-
62-
console.log("getDaoTokensReceipt");
63-
console.log(getDaoTokensReceipt);
61+
const getDaoTokensReceipts = [
62+
getDaoTokens(deployer, deployer, 1000000000), // 1000 STX
63+
getDaoTokens(deployer, address1, 500000000), // 500 STX
64+
getDaoTokens(deployer, address2, 250000000), // 250 STX
65+
];
66+
67+
console.log("===========================");
68+
console.log("getDaoTokensReceipts");
69+
for (const receipt of getDaoTokensReceipts) {
70+
console.log(receipt);
71+
}
6472

6573
// construct DAO
6674
const constructReceipt = constructDao(deployer);
6775

76+
console.log("===========================");
6877
console.log("constructReceipt");
6978
console.log(constructReceipt);
7079

80+
simnet.mineEmptyBlocks(10);
81+
7182
// pass proposal
7283
const proposalReceipt = passCoreProposal(proposalContractAddress, deployer);
7384

85+
console.log("===========================");
7486
console.log("proposalReceipt");
7587
console.log(proposalReceipt);
7688

@@ -81,8 +93,9 @@ describe(`extension: ${contractName}`, () => {
8193
deployer
8294
);
8395

96+
console.log("===========================");
8497
console.log("proposalDetails");
85-
console.log(cvToValue(proposalDetails.result));
98+
console.log(cvToValue(proposalDetails.result).value);
8699

87100
simnet.mineEmptyBlocks(100);
88101

@@ -93,6 +106,7 @@ describe(`extension: ${contractName}`, () => {
93106
deployer
94107
);
95108

109+
console.log("===========================");
96110
console.log("votingPowerReceipt");
97111
console.log(cvToValue(votingPowerReceipt.result));
98112

@@ -103,6 +117,7 @@ describe(`extension: ${contractName}`, () => {
103117
deployer
104118
);
105119

120+
console.log("===========================");
106121
console.log("addressBalanceReceipt");
107122
console.log(cvToValue(addressBalanceReceipt.result));
108123

@@ -113,18 +128,10 @@ describe(`extension: ${contractName}`, () => {
113128
deployer
114129
);
115130

131+
console.log("===========================");
116132
console.log("voteReceipt");
117133
console.log(voteReceipt);
118134

119135
expect(voteReceipt.result).toBeOk(Cl.bool(true));
120136
});
121-
122-
/*
123-
// Message Tests
124-
describe("send()", () => {
125-
it("succeeds if called by any user with isFromDao false");
126-
it("fails if called by any user with isFromDao true");
127-
it("succeeds if called by a DAO proposal with isFromDao true");
128-
});
129-
*/
130137
});

tests/test-utilities.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ function getPercentageOfSupply(amount: number, totalSupply: number) {
99
return `${percentage}% supply`;
1010
}
1111

12-
export function getDaoTokens(deployer: string, address: string) {
12+
export function getDaoTokens(
13+
deployer: string,
14+
address: string,
15+
stxAmount: number
16+
) {
1317
const tokenContractName = "aibtc-token";
1418
const tokenContractAddress = `${deployer}.${tokenContractName}`;
1519
const tokenDexContractName = "aibtc-token-dex";
@@ -47,8 +51,8 @@ export function getDaoTokens(deployer: string, address: string) {
4751

4852
const liquidTokenSupply = totalSupply - treasuryBalance - tokenDexBalance;
4953

50-
console.log("BEFORE BUY");
5154
console.log("=========================");
55+
console.log("BEFORE BUY");
5256
console.log("totalSupply", totalSupply);
5357
console.log(
5458
"treasuryBalance",
@@ -69,7 +73,7 @@ export function getDaoTokens(deployer: string, address: string) {
6973
const getDaoTokensReceipt = simnet.callPublicFn(
7074
tokenDexContractAddress,
7175
"buy",
72-
[Cl.principal(tokenContractAddress), Cl.uint(1000000000)], // 1000 STX buy test
76+
[Cl.principal(tokenContractAddress), Cl.uint(stxAmount)], // 1000 STX buy test
7377
address
7478
);
7579

@@ -111,8 +115,8 @@ export function getDaoTokens(deployer: string, address: string) {
111115

112116
const liquidTokenSupply2 = totalSupply2 - treasuryBalance2 - tokenDexBalance2;
113117

114-
console.log("AFTER BUY");
115118
console.log("=========================");
119+
console.log("AFTER BUY");
116120
console.log("totalSupply2", totalSupply2);
117121
console.log(
118122
"treasuryBalance2",
@@ -135,8 +139,8 @@ export function getDaoTokens(deployer: string, address: string) {
135139
);
136140
const addressVotingPower = addressBalance / liquidTokenSupply2;
137141

138-
console.log("ADDRESS INFO");
139142
console.log("=========================");
143+
console.log("ADDRESS INFO");
140144
console.log(
141145
"addressBalance",
142146
addressBalance,
@@ -175,6 +179,7 @@ export function constructDao(deployer: string) {
175179
export function passCoreProposal(
176180
proposalContractAddress: string,
177181
deployer: string
182+
// voters: string[]
178183
) {
179184
// create-proposal
180185
const createProposalReceipt = simnet.callPublicFn(

0 commit comments

Comments
 (0)