diff --git a/contracts/tests/DSocialNetworkAccount.spec.ts b/contracts/tests/DSocialNetworkAccount.spec.ts new file mode 100644 index 00000000..a112c579 --- /dev/null +++ b/contracts/tests/DSocialNetworkAccount.spec.ts @@ -0,0 +1,66 @@ +import { Blockchain, SandboxContract } from '@ton-community/sandbox' +import { toNano } from 'ton-core' +import { DSocialNetworkMaster } from '../wrappers/DSocialNetworkMaster' +import { DSocialNetworkAccount } from '../wrappers/DSocialNetworkAccount' +import '@ton-community/test-utils' + +describe('DSocialNetworkMaster', () => { + let blockchain: Blockchain + let deployer: Awaited> + let dMaster: SandboxContract + let dAccount: SandboxContract + + beforeEach(async () => { + blockchain = await Blockchain.create() + dMaster = blockchain.openContract(await DSocialNetworkMaster.fromInit()) + deployer = await blockchain.treasury('deployer') + const deployResult = await dMaster.send( + deployer.getSender(), + { value: toNano('0.05') }, + { + $$type: 'Deploy', + queryId: 0n + } + ) + + expect(deployResult.transactions).toHaveTransaction({ + from: deployer.address, + to: dMaster.address, + deploy: true, + success: true + }) + + const registerResult = await dMaster.send( + deployer.getSender(), + { value: toNano('0.5') }, + { + $$type: 'RegisterAccount', + query_id: 0n, + account_name: 'name', + account_description: 'Account description' + } + ) + + const accountAddress = await dMaster.getGetAccountAddressByIndex(0n) + + expect(accountAddress).not.toBeNull() + + expect(registerResult.transactions).toHaveTransaction({ + from: dMaster.address, + to: accountAddress!, + success: true + }) + + expect(await dMaster.getGetAccountsCount()).toBe(1n) + + dAccount = blockchain.openContract( + DSocialNetworkAccount.fromAddress(accountAddress!) + ) + }) + + it('deployer shoud be owner of the account', async () => { + const owner = await dAccount.getOwner() + + expect(owner.toRawString()).toEqual(deployer.address.toRawString()) + }) +}) diff --git a/contracts/tests/DSocialNetworkMaster.spec.ts b/contracts/tests/DSocialNetworkMaster.spec.ts index ce1ca404..5552db46 100644 --- a/contracts/tests/DSocialNetworkMaster.spec.ts +++ b/contracts/tests/DSocialNetworkMaster.spec.ts @@ -44,8 +44,7 @@ describe('DSocialNetworkMaster', () => { $$type: 'RegisterAccount', query_id: 0n, account_name: 'd0rich', - account_description: - 'This is my first account sadsadasdasdasdsadadasdsadsadsadsadasdasdadadasdasdsadasdsadadasdadasdasdasdasdasdasdasdasdadasdadasdadasdasdasdsadasdadadsdaddsadsadadd' + account_description: 'This is my first account' } )