Skip to content

Commit

Permalink
fix: update tests for long strings in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ya7on committed Oct 28, 2024
1 parent a2dad75 commit 55620bf
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 81 deletions.
8 changes: 4 additions & 4 deletions scripts/deployJettonMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function run(provider: NetworkProvider) {
}
);

await provider.waitForDeploy(jettonMaster.address);
await provider.waitForDeploy(jettonMaster.address, 100, 5000);

await jettonMaster.send(
provider.sender(),
Expand All @@ -26,9 +26,9 @@ export async function run(provider: NetworkProvider) {
{
$$type: 'JettonInit',
query_id: 0n,
jetton_name: new Builder().storeStringTail('Jetton name').asSlice(),
jetton_description: new Builder().storeStringTail('Long' + ' long '.repeat(1) + 'description').asSlice(),
jetton_symbol: new Builder().storeStringTail('SMBL').asSlice(),
jetton_name: new Builder().storeStringRefTail('Jetton name').asSlice(),
jetton_description: new Builder().storeStringRefTail('Long' + ' long '.repeat(100) + 'description').asSlice(),
jetton_symbol: new Builder().storeStringRefTail('SMBL').asSlice(),
max_supply: toNano(1337),
}
);
Expand Down
142 changes: 65 additions & 77 deletions tests/JettonMaster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,83 +65,71 @@ describe('JettonMaster', () => {
});

it('should handle big strings', async () => {
// const LONG_JETTON_NAME = JETTON_NAME.repeat(100);
// const LONG_JETTON_DESCRIPTION = JETTON_DESCRIPTION.repeat(20);
// const LONG_JETTON_SYMBOL = JETTON_SYMBOL.repeat(200);

// expect(LONG_JETTON_NAME.length).toBeGreaterThan(1024);
// expect(LONG_JETTON_DESCRIPTION.length).toBeGreaterThan(1024);
// expect(LONG_JETTON_SYMBOL.length).toBeGreaterThan(1024);

// const otherJettonMaster = blockchain.openContract(await JettonMaster.fromInit(other.address));
// await otherJettonMaster.send(
// other.getSender(),
// {
// value: toNano("0.05"),
// },
// {
// $$type: 'Deploy',
// queryId: 0n,
// }
// );
// const deployResult = await other.send({
// to: otherJettonMaster.address,
// value: toNano("0.05"),
// body: new Builder()
// .storeUint(0x133701, 32)
// .storeUint(0, 64)
// .storeRef(new Builder().storeStringTail(LONG_JETTON_NAME).asCell())
// .storeRef(new Builder().storeStringTail(JETTON_DESCRIPTION).asCell())
// .storeRef(new Builder().storeStringTail(JETTON_SYMBOL).asCell())
// .storeCoins(JETTON_MAX_SUPPLY)
// .asCell()
// });
// const deployResult = await otherJettonMaster.send(
// other.getSender(),
// {
// value: toNano("0.05"),
// },
// {
// $$type: 'JettonInit',
// query_id: 0n,
// jetton_name: new Builder().storeStringTail(LONG_JETTON_NAME).asCell().asSlice(),
// jetton_description: new Builder().storeStringTail(LONG_JETTON_DESCRIPTION).asCell().asSlice(),
// jetton_symbol: new Builder().storeStringTail(LONG_JETTON_SYMBOL).asCell().asSlice(),
// max_supply: JETTON_MAX_SUPPLY,
// }
// );
// expect(deployResult.transactions).toHaveTransaction({
// from: other.address,
// to: otherJettonMaster.address,
// success: true,
// op: 0x133701,
// });
// expect(deployResult.transactions).toHaveTransaction({
// from: otherJettonMaster.address,
// to: other.address,
// success: true,
// deploy: false,
// op: 0x133702,
// });
// let metadataResult = await otherJettonMaster.getGetJettonData();
// let jettonContent = metadataResult.jetton_content.beginParse();
// expect(jettonContent.loadUint(8)).toEqual(0);
// let metadataDict = jettonContent.loadDict(Dictionary.Keys.BigUint(256), Dictionary.Values.Cell());
// expect(
// metadataDict.get(59089242681608890680090686026688704441792375738894456860693970539822503415433n)
// ).toEqualCell(
// beginCell().storeUint(0, 8).storeStringTail(LONG_JETTON_NAME).endCell()
// );
// expect(
// metadataDict.get(82961397245523513629401799123410942652413991882008909918554405086738284660097n)
// ).toEqualCell(
// beginCell().storeUint(0, 8).storeStringTail(LONG_JETTON_SYMBOL).endCell()
// );
// expect(
// metadataDict.get(90922719342317012409671596374183159143637506542604000676488204638996496437508n)
// ).toEqualCell(
// beginCell().storeUint(0, 8).storeStringTail(LONG_JETTON_DESCRIPTION).endCell()
// );
const LONG_JETTON_NAME = JETTON_NAME.repeat(100);
const LONG_JETTON_DESCRIPTION = JETTON_DESCRIPTION.repeat(20);
const LONG_JETTON_SYMBOL = JETTON_SYMBOL.repeat(200);

expect(LONG_JETTON_NAME.length).toBeGreaterThan(1024);
expect(LONG_JETTON_DESCRIPTION.length).toBeGreaterThan(1024);
expect(LONG_JETTON_SYMBOL.length).toBeGreaterThan(1024);

const otherJettonMaster = blockchain.openContract(await JettonMaster.fromInit(other.address));
await otherJettonMaster.send(
other.getSender(),
{
value: toNano("0.05"),
},
{
$$type: 'Deploy',
queryId: 0n,
}
);
const deployResult = await otherJettonMaster.send(
other.getSender(),
{
value: toNano("0.05"),
},
{
$$type: 'JettonInit',
query_id: 0n,
jetton_name: beginCell().storeStringRefTail(LONG_JETTON_NAME).asCell().asSlice(),
jetton_description: beginCell().storeStringRefTail(LONG_JETTON_DESCRIPTION).asCell().asSlice(),
jetton_symbol: beginCell().storeStringRefTail(LONG_JETTON_SYMBOL).asCell().asSlice(),
max_supply: JETTON_MAX_SUPPLY,
}
);
expect(deployResult.transactions).toHaveTransaction({
from: other.address,
to: otherJettonMaster.address,
success: true,
op: 0x133701,
});
expect(deployResult.transactions).toHaveTransaction({
from: otherJettonMaster.address,
to: other.address,
success: true,
deploy: false,
op: 0x133702,
});
let metadataResult = await otherJettonMaster.getGetJettonData();
let jettonContent = metadataResult.jetton_content.beginParse();
expect(jettonContent.loadUint(8)).toEqual(0);
let metadataDict = jettonContent.loadDict(Dictionary.Keys.BigUint(256), Dictionary.Values.Cell());
expect(
metadataDict.get(59089242681608890680090686026688704441792375738894456860693970539822503415433n)
).toEqualCell(
beginCell().storeUint(0, 8).storeStringRefTail(LONG_JETTON_NAME).endCell()
);
expect(
metadataDict.get(82961397245523513629401799123410942652413991882008909918554405086738284660097n)
).toEqualCell(
beginCell().storeUint(0, 8).storeStringRefTail(LONG_JETTON_SYMBOL).endCell()
);
expect(
metadataDict.get(90922719342317012409671596374183159143637506542604000676488204638996496437508n)
).toEqualCell(
beginCell().storeUint(0, 8).storeStringRefTail(LONG_JETTON_DESCRIPTION).endCell()
);
});

it('should correct build wallet address', async () => {
Expand Down

0 comments on commit 55620bf

Please sign in to comment.