Skip to content

Commit c30efb3

Browse files
committed
Update cairo-stable ERC20 tests
1 parent 7149d9c commit c30efb3

File tree

3 files changed

+176
-17
lines changed

3 files changed

+176
-17
lines changed

packages/core/cairo/src/erc20.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function testERC20(title: string, opts: Partial<ERC20Options>) {
1212
const c = buildERC20({
1313
name: 'MyToken',
1414
symbol: 'MTK',
15+
decimals: '18',
1516
...opts,
1617
});
1718
t.snapshot(printContract(c));
@@ -29,6 +30,7 @@ function testAPIEquivalence(title: string, opts?: ERC20Options) {
2930
buildERC20({
3031
name: 'MyToken',
3132
symbol: 'MTK',
33+
decimals: '18',
3234
...opts,
3335
}),
3436
),
@@ -69,6 +71,21 @@ testERC20('erc20 premint of 0', {
6971
premint: '0',
7072
});
7173

74+
testERC20('erc20 votes, custom decimals', {
75+
decimals: '6',
76+
});
77+
78+
test('erc20 votes, decimals too high', async t => {
79+
const error = t.throws(() =>
80+
buildERC20({
81+
name: 'MyToken',
82+
symbol: 'MTK',
83+
decimals: '256',
84+
}),
85+
);
86+
t.is((error as OptionsError).messages.decimals, 'Value is greater than u8 max value');
87+
});
88+
7289
testERC20('erc20 mintable', {
7390
mintable: true,
7491
access: 'ownable',
@@ -95,6 +112,7 @@ test('erc20 votes, no name', async t => {
95112
buildERC20({
96113
name: 'MyToken',
97114
symbol: 'MTK',
115+
decimals: '18',
98116
votes: true,
99117
}),
100118
);
@@ -106,6 +124,7 @@ test('erc20 votes, empty version', async t => {
106124
buildERC20({
107125
name: 'MyToken',
108126
symbol: 'MTK',
127+
decimals: '18',
109128
votes: true,
110129
appName: 'MY_DAPP_NAME',
111130
appVersion: '', // avoids default value of v1
@@ -158,11 +177,12 @@ testERC20('erc20 full upgradeable with roles', {
158177

159178
testAPIEquivalence('erc20 API default');
160179

161-
testAPIEquivalence('erc20 API basic', { name: 'CustomToken', symbol: 'CTK' });
180+
testAPIEquivalence('erc20 API basic', { name: 'CustomToken', symbol: 'CTK', decimals: '6' });
162181

163182
testAPIEquivalence('erc20 API full upgradeable', {
164183
name: 'CustomToken',
165184
symbol: 'CTK',
185+
decimals: '6',
166186
premint: '2000',
167187
access: 'roles',
168188
burnable: true,

0 commit comments

Comments
 (0)