Skip to content

Commit

Permalink
Reuse similar messages
Browse files Browse the repository at this point in the history
  • Loading branch information
d0rich committed Nov 17, 2023
1 parent 30aa34d commit 6c2fce8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 50 deletions.
26 changes: 6 additions & 20 deletions contracts/scripts/deployTestSocialNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { NetworkProvider } from '@ton-community/blueprint'
import { DSocialNetworkMaster } from '../wrappers/DSocialNetworkMaster'
import { DSocialNetworkAccount } from '../wrappers/DSocialNetworkAccount'
import { DSocialNetworkPost } from '../wrappers/DSocialNetworkPost'
import {
createTestPostMessage,
registerTestAccountMessage
} from '../utils/test'

export async function run(provider: NetworkProvider) {
const dMaster = provider.open(await DSocialNetworkMaster.fromInit())
Expand All @@ -23,16 +27,7 @@ export async function run(provider: NetworkProvider) {
await dMaster.send(
provider.sender(),
{ value: toNano('0.5') },
{
$$type: 'RegisterAccount',
query_id: 0n,
account_metadata_json: JSON.stringify({
image: 'https://d0rich.me/og/image.jpg',
name: 'test',
description: 'Test account description',
social_links: ['https://d0rich.t.me']
})
}
registerTestAccountMessage
)

const accountAddress = await dMaster.getGetAccountAddressByIndex(0n)
Expand All @@ -46,16 +41,7 @@ export async function run(provider: NetworkProvider) {
await dAccount.send(
provider.sender(),
{ value: toNano('0.5') },
{
$$type: 'MintNft',
query_id: 0n,
individual_content: JSON.stringify({
name: 'Test post',
description: 'Test post description',
image: 'https://d0rich.me/og/image.jpg',
content_url: 'https://test.com/content.txt'
})
}
createTestPostMessage
)

const postAddress = await dAccount.getGetNftAddressByIndex(0n)
Expand Down
26 changes: 6 additions & 20 deletions contracts/tests/DSocialNetworkAccount.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { DSocialNetworkMaster } from '../wrappers/DSocialNetworkMaster'
import { DSocialNetworkAccount } from '../wrappers/DSocialNetworkAccount'
import '@ton-community/test-utils'
import { DSocialNetworkPost } from '../wrappers/DSocialNetworkPost'
import {
createTestPostMessage,
registerTestAccountMessage
} from '../utils/test'

describe('DSocialNetworkMaster', () => {
let blockchain: Blockchain
Expand Down Expand Up @@ -34,16 +38,7 @@ describe('DSocialNetworkMaster', () => {
const registerResult = await dMaster.send(
deployer.getSender(),
{ value: toNano('0.5') },
{
$$type: 'RegisterAccount',
query_id: 0n,
account_metadata_json: JSON.stringify({
image: 'https://d0rich.me/og/image.jpg',
name: 'test',
description: 'Test account description',
social_links: ['https://d0rich.t.me']
})
}
registerTestAccountMessage
)

const accountAddress = await dMaster.getGetAccountAddressByIndex(0n)
Expand Down Expand Up @@ -73,16 +68,7 @@ describe('DSocialNetworkMaster', () => {
const registerResult = await dAccount.send(
deployer.getSender(),
{ value: toNano('0.5') },
{
$$type: 'MintNft',
query_id: 0n,
individual_content: JSON.stringify({
name: 'Test post',
description: 'Test post description',
image: 'https://d0rich.me/og/image.jpg',
content_url: 'https://test.com/content.txt'
})
}
createTestPostMessage
)

const postAddress = await dAccount.getGetNftAddressByIndex(0n)
Expand Down
12 changes: 2 additions & 10 deletions contracts/tests/DSocialNetworkMaster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { toNano } from 'ton-core'
import { DSocialNetworkMaster } from '../wrappers/DSocialNetworkMaster'
import { DSocialNetworkAccount } from '../wrappers/DSocialNetworkAccount'
import '@ton-community/test-utils'
import { registerTestAccountMessage } from '../utils/test'

describe('DSocialNetworkMaster', () => {
let blockchain: Blockchain
Expand Down Expand Up @@ -40,16 +41,7 @@ describe('DSocialNetworkMaster', () => {
const registerResult = await dMaster.send(
deployer.getSender(),
{ value: toNano('0.5') },
{
$$type: 'RegisterAccount',
query_id: 0n,
account_metadata_json: JSON.stringify({
image: 'https://d0rich.me/og/image.jpg',
name: 'test',
description: 'Test account description',
social_links: ['https://d0rich.t.me']
})
}
registerTestAccountMessage
)

const accountAddress = await dMaster.getGetAccountAddressByIndex(0n)
Expand Down
24 changes: 24 additions & 0 deletions contracts/utils/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { RegisterAccount } from '../wrappers/DSocialNetworkMaster'
import { MintNft } from '../wrappers/DSocialNetworkAccount'

export const registerTestAccountMessage: RegisterAccount = {
$$type: 'RegisterAccount',
query_id: 0n,
account_metadata_json: JSON.stringify({
image: 'https://d0rich.me/og/image.jpg',
name: 'test',
description: 'Test account description',
social_links: ['https://d0rich.t.me']
})
}

export const createTestPostMessage: MintNft = {
$$type: 'MintNft',
query_id: 0n,
individual_content: JSON.stringify({
name: 'Test post',
description: 'Test post description',
image: 'https://d0rich.me/og/image.jpg',
content_url: 'https://test.com/content.txt'
})
}

0 comments on commit 6c2fce8

Please sign in to comment.