-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix e2e tests for remaining packages
- Loading branch information
1 parent
91b0b49
commit d1ca9ad
Showing
37 changed files
with
920 additions
and
264 deletions.
There are no files selected for viewing
This file contains 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 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 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
44 changes: 23 additions & 21 deletions
44
packages/deepbook/test/e2e/data/test_coin/sources/test_coin.move
This file contains 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,29 +1,31 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module test_coin::test { | ||
use std::option; | ||
use sui::coin; | ||
use sui::transfer; | ||
use sui::url; | ||
use sui::tx_context::{Self, TxContext}; | ||
module test_coin::test; | ||
|
||
public struct TEST has drop {} | ||
use sui::coin; | ||
use sui::url; | ||
|
||
fun init(witness: TEST, ctx: &mut TxContext) { | ||
let (mut treasury_cap, metadata) = coin::create_currency<TEST>( | ||
witness, | ||
2, | ||
b"TEST", | ||
b"Test Coin", | ||
b"Test coin metadata", | ||
option::some(url::new_unsafe_from_bytes(b"http://sui.io")), | ||
ctx | ||
); | ||
public struct TEST has drop {} | ||
|
||
coin::mint_and_transfer<TEST>(&mut treasury_cap, 1000, tx_context::sender(ctx), ctx); | ||
fun init(witness: TEST, ctx: &mut TxContext) { | ||
let (mut treasury_cap, metadata) = coin::create_currency<TEST>( | ||
witness, | ||
2, | ||
b"TEST", | ||
b"Test Coin", | ||
b"Test coin metadata", | ||
option::some(url::new_unsafe_from_bytes(b"http://sui.io")), | ||
ctx, | ||
); | ||
|
||
transfer::public_share_object(metadata); | ||
transfer::public_share_object(treasury_cap) | ||
} | ||
coin::mint_and_transfer<TEST>( | ||
&mut treasury_cap, | ||
1000, | ||
tx_context::sender(ctx), | ||
ctx, | ||
); | ||
|
||
transfer::public_share_object(metadata); | ||
transfer::public_share_object(treasury_cap) | ||
} |
This file contains 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,70 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { resolve } from 'path'; | ||
import { GenericContainer, Network } from 'testcontainers'; | ||
import type { GlobalSetupContext } from 'vitest/node'; | ||
|
||
declare module 'vitest' { | ||
export interface ProvidedContext { | ||
localnetPort: number; | ||
graphqlPort: number; | ||
faucetPort: number; | ||
suiToolsContainerId: string; | ||
} | ||
} | ||
|
||
const SUI_TOOLS_TAG = process.env.SUI_TOOLS_TAG || '2e256a70aa0ff81972ded6ebd57f7679e2ea194d-arm64'; | ||
|
||
export default async function setup({ provide }: GlobalSetupContext) { | ||
console.log('Starting test containers'); | ||
const network = await new Network().start(); | ||
|
||
const pg = await new GenericContainer('postgres') | ||
.withEnvironment({ | ||
POSTGRES_USER: 'postgres', | ||
POSTGRES_PASSWORD: 'postgrespw', | ||
POSTGRES_DB: 'sui_indexer_v2', | ||
}) | ||
.withCommand(['-c', 'max_connections=500']) | ||
|
||
.withExposedPorts(5432) | ||
.withNetwork(network) | ||
.start(); | ||
|
||
const localnet = await new GenericContainer(`mysten/sui-tools:${SUI_TOOLS_TAG}`) | ||
.withCommand([ | ||
'sui', | ||
'start', | ||
'--with-faucet', | ||
'--force-regenesis', | ||
'--with-indexer', | ||
'--pg-port', | ||
'5432', | ||
'--pg-db-name', | ||
'sui_indexer_v2', | ||
'--pg-host', | ||
pg.getIpAddress(network.getName()), | ||
'--pg-user', | ||
'postgres', | ||
'--pg-password', | ||
'postgrespw', | ||
'--with-graphql', | ||
]) | ||
.withCopyDirectoriesToContainer([ | ||
{ source: resolve(__dirname, './data'), target: '/test-data' }, | ||
]) | ||
.withNetwork(network) | ||
.withExposedPorts(9000, 9123, 9124, 9125) | ||
.withLogConsumer((stream) => { | ||
stream.on('data', (data) => { | ||
console.log(data.toString()); | ||
}); | ||
}) | ||
.start(); | ||
|
||
provide('faucetPort', localnet.getMappedPort(9123)); | ||
provide('localnetPort', localnet.getMappedPort(9124)); | ||
provide('graphqlPort', localnet.getMappedPort(9125)); | ||
provide('suiToolsContainerId', localnet.getId()); | ||
} |
This file contains 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 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,12 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { inject } from 'vitest'; | ||
|
||
Object.entries({ | ||
FAUCET_URL: `http://localhost:${inject('faucetPort')}`, | ||
FULLNODE_URL: `http://localhost:${inject('localnetPort')}`, | ||
GRAPHQL_URL: `http://localhost:${inject('graphqlPort')}`, | ||
}).forEach(([key, value]) => { | ||
process.env[key] = value; | ||
}); |
This file contains 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,10 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["../../**/*.ts"], | ||
"compilerOptions": { | ||
"module": "CommonJS", | ||
"outDir": "dist/cjs", | ||
"isolatedModules": true, | ||
"rootDir": "../.." | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.