-
Notifications
You must be signed in to change notification settings - Fork 211
test(benches): add nft test #3159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
skywardboundd
wants to merge
27
commits into
main
Choose a base branch
from
3154-add-tests-for-all-benchmarks-projects-nft
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
aafaa22
test(benches): add nft test
skywardboundd 0031005
feat(bench): separate test and benchmark runners
skywardboundd 91c928f
fmt
skywardboundd 9e48e8e
fix
skywardboundd b6a6c8b
fix x2
skywardboundd d1ed5d9
add allure steps
skywardboundd 8b87036
fix
skywardboundd 2ca66e9
fix add/update script
skywardboundd bcec36f
fmt
skywardboundd b0c6ac8
xd
skywardboundd f55983e
upd
skywardboundd 1b984ba
fix
skywardboundd 23ba1b2
fix x2
skywardboundd 04386b3
Merge branch 'main' into 3154-add-tests-for-all-benchmarks-projects-nft
skywardboundd 730a190
fix
skywardboundd 419a412
Merge remote-tracking branch 'origin/main' into 3154-add-tests-for-al…
skywardboundd a353727
temp
skywardboundd 5d0407c
upd
skywardboundd a35260e
delete unused filter
skywardboundd 931f95d
Merge branch 'main' into 3154-add-tests-for-all-benchmarks-projects-nft
skywardboundd fee14a1
small refactor
skywardboundd 4ee18ff
Merge branch 'main' into 3154-add-tests-for-all-benchmarks-projects-nft
skywardboundd bc739c2
review
skywardboundd 573c2aa
fmt
skywardboundd 9c31f10
Merge branch 'main' into 3154-add-tests-for-all-benchmarks-projects-nft
skywardboundd f375be9
final fix
skywardboundd 9e0fbca
small fix
skywardboundd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAU | ||
| Aksakov | ||
| Aliaksandr | ||
| alnum | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| import "@ton/test-utils"; | ||
| import type { Address } from "@ton/core"; | ||
| import { Cell, beginCell, contractAddress } from "@ton/core"; | ||
|
|
||
| import { | ||
| generateResults, | ||
| generateCodeSizeResults, | ||
| printBenchmarkTable, | ||
| type BenchmarkResult, | ||
| type CodeSizeResult, | ||
| } from "@/benchmarks/utils/gas"; | ||
| import { resolve } from "path"; | ||
| import { readFileSync } from "fs"; | ||
| import { posixNormalize } from "@/utils/filePath"; | ||
|
|
||
| import { NFTCollection } from "@/benchmarks/nft/tact/output/collection_NFTCollection"; | ||
| import type { RoyaltyParams } from "@/benchmarks/nft/tact/output/collection_NFTCollection"; | ||
| import { NFTItem } from "@/benchmarks/nft/tact/output/collection_NFTItem"; | ||
|
|
||
| import benchmarkResults from "@/benchmarks/nft/gas.json"; | ||
| import benchmarkCodeSizeResults from "@/benchmarks/nft/size.json"; | ||
|
|
||
| const loadFunCNFTBoc = () => { | ||
| const bocCollection = readFileSync( | ||
| posixNormalize(resolve(__dirname, "./func/output/nft-collection.boc")), | ||
| ); | ||
|
|
||
| const bocItem = readFileSync( | ||
| posixNormalize(resolve(__dirname, "./func/output/nft-item.boc")), | ||
| ); | ||
|
|
||
| return { bocCollection, bocItem }; | ||
| }; | ||
|
|
||
| const fromInitCollection = ( | ||
| owner: Address, | ||
| index: bigint, | ||
| content: Cell, | ||
| royaltyParams: RoyaltyParams, | ||
| ) => { | ||
| const nftData = loadFunCNFTBoc(); | ||
| const __code = Cell.fromBoc(nftData.bocCollection)[0]!; | ||
|
|
||
| const royaltyCell = beginCell() | ||
| .storeUint(royaltyParams.nominator, 16) | ||
| .storeUint(royaltyParams.dominator, 16) | ||
| .storeAddress(royaltyParams.owner) | ||
| .endCell(); | ||
|
|
||
| const __data = beginCell() | ||
| .storeAddress(owner) | ||
| .storeUint(index, 64) | ||
| .storeRef(content) | ||
| .storeRef(Cell.fromBoc(nftData.bocItem)[0]!) | ||
| .storeRef(royaltyCell) | ||
| .endCell(); | ||
|
|
||
| const __gen_init = { code: __code, data: __data }; | ||
| const address = contractAddress(0, __gen_init); | ||
| return Promise.resolve(new NFTCollection(address, __gen_init)); | ||
| }; | ||
|
|
||
| const fromInitItem = ( | ||
| _owner: Address | null, | ||
| _content: Cell | null, | ||
| collectionAddress: Address, | ||
| itemIndex: bigint, | ||
| ) => { | ||
| const nftData = loadFunCNFTBoc(); | ||
| const __code = Cell.fromBoc(nftData.bocItem)[0]!; | ||
|
|
||
| const __data = beginCell() | ||
| .storeUint(itemIndex, 64) | ||
| .storeAddress(collectionAddress) | ||
| .endCell(); | ||
|
|
||
| const __gen_init = { code: __code, data: __data }; | ||
| const address = contractAddress(0, __gen_init); | ||
| return Promise.resolve(new NFTItem(address, __gen_init)); | ||
| }; | ||
|
|
||
| export const run = ( | ||
| testNFT: ( | ||
| benchmarkResults: BenchmarkResult, | ||
| codeSizeResults: CodeSizeResult, | ||
| fromInitCollection: ( | ||
| owner: Address, | ||
| index: bigint, | ||
| content: Cell, | ||
| royaltyParams: RoyaltyParams, | ||
| ) => Promise<NFTCollection>, | ||
| fromInitItem: ( | ||
| owner: Address | null, | ||
| content: Cell | null, | ||
| collectionAddress: Address, | ||
| itemIndex: bigint, | ||
| ) => Promise<NFTItem>, | ||
| ) => void, | ||
| ) => { | ||
| describe("NFT Gas Tests", () => { | ||
| const fullResults = generateResults(benchmarkResults); | ||
| const fullCodeSizeResults = generateCodeSizeResults( | ||
| benchmarkCodeSizeResults, | ||
| ); | ||
|
|
||
| describe("func", () => { | ||
| const funcCodeSize = fullCodeSizeResults.at(0)!; | ||
| const funcResult = fullResults.at(0)!; | ||
|
|
||
| testNFT(funcResult, funcCodeSize, fromInitCollection, fromInitItem); | ||
| }); | ||
|
|
||
| describe("tact", () => { | ||
| const tactCodeSize = fullCodeSizeResults.at(-1)!; | ||
| const tactResult = fullResults.at(-1)!; | ||
| testNFT( | ||
| tactResult, | ||
| tactCodeSize, | ||
| NFTCollection.fromInit.bind(NFTCollection), | ||
| NFTItem.fromInit.bind(NFTItem), | ||
| ); | ||
| }); | ||
|
|
||
| afterAll(() => { | ||
| printBenchmarkTable(fullResults, fullCodeSizeResults, { | ||
| implementationName: "FunC", | ||
| printMode: "full", | ||
| }); | ||
| }); | ||
| }); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { type FromInitItem, testItem } from "@/benchmarks/nft/tests/item"; | ||
| import { | ||
| type FromInitCollection, | ||
| testCollection, | ||
| } from "@/benchmarks/nft/tests/collection"; | ||
|
|
||
| import type { BenchmarkResult, CodeSizeResult } from "@/benchmarks/utils/gas"; | ||
|
|
||
| export const testNFT = ( | ||
| _benchmarkResults: BenchmarkResult, | ||
| _codeSizeResults: CodeSizeResult, | ||
| fromInitCollection: FromInitCollection, | ||
| fromInitItem: FromInitItem, | ||
| ) => { | ||
| testItem(fromInitItem); | ||
| testCollection(fromInitCollection, fromInitItem); | ||
| }; | ||
|
|
||
| import { run } from "@/benchmarks/nft/run"; | ||
|
|
||
| run(testNFT); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.