-
Notifications
You must be signed in to change notification settings - Fork 822
test: Test setup refactor & remove RPC sequencer #1044
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
Merged
ivpavici
merged 13 commits into
starknet-io:next-version
from
lukasaric:chore/remove-sequencer-and-test-setup-refactor
Apr 8, 2024
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6d057f7
test: test setup refactor & remove rpc sequencer
2992590
fix: enable sequencer tests to run on goerli
109fe15
chore: format markdowns
9cc532e
fix: remove unnecessary goerli describeIf comment
415f152
chore: remove setup verifier & simplify envs check logic
f8ddeef
Merge branch 'develop' into chore/remove-sequencer-and-test-setup-ref…
76eeb82
Merge branch 'develop' into chore/remove-sequencer-and-test-setup-ref…
652e6bb
test: naming improvements
8f83e3a
test: update test setup data log for testnet
55d36ad
test: change from goerli to sepolia
d94a6b3
test: rename from rpc testnet to testnet
6481eb0
test: remove `TEST_PROVIDER_BASE_URL`
04f6885
Merge branch 'next-version' into chore/remove-sequencer-and-test-setu…
ivpavici 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
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 |
---|---|---|
@@ -1,2 +1,10 @@ | ||
/* Default test config based on run `starknet-devnet --seed 0` */ | ||
export const GS_DEFAULT_TEST_PROVIDER_URL = 'http://127.0.0.1:5050/'; | ||
|
||
export const LOCAL_DEVNET_NOT_RUNNING_MESSAGE = ` | ||
Local devnet is not running. In order to properly run it you need to do the following: \n | ||
- Go to the: https://hub.docker.com/r/shardlabs/starknet-devnet-rs/tags | ||
- Find the latest tag and copy the "docker pull" command | ||
- Run Docker on your machine | ||
- Run the command: "docker pull shardlabs/starknet-devnet-rs:latest" | ||
`; |
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,64 @@ | ||
/* eslint-disable no-console */ | ||
import { GS_DEFAULT_TEST_PROVIDER_URL } from '../constants'; | ||
|
||
class AccountResolver { | ||
get providedUrl() { | ||
return process.env.TEST_PROVIDER_BASE_URL || process.env.TEST_RPC_URL; | ||
} | ||
|
||
get hasAllAccountEnvs() { | ||
return process.env.TEST_ACCOUNT_ADDRESS && process.env.TEST_ACCOUNT_PRIVATE_KEY; | ||
} | ||
|
||
get hasPartialAccountEnvs() { | ||
return process.env.TEST_ACCOUNT_ADDRESS || process.env.TEST_ACCOUNT_PRIVATE_KEY; | ||
} | ||
|
||
private async fetchAccount(url: string) { | ||
const response = await fetch(`${url}predeployed_accounts`); | ||
const [account] = await response.json(); | ||
const { address, private_key, initial_balance } = account; | ||
process.env.TEST_ACCOUNT_ADDRESS = address; | ||
process.env.TEST_ACCOUNT_PRIVATE_KEY = private_key; | ||
process.env.INITIAL_BALANCE = initial_balance; | ||
} | ||
|
||
private async isAccountSet(isDevnet: boolean): Promise<boolean> { | ||
if (this.hasAllAccountEnvs) { | ||
return true; | ||
} | ||
if (this.hasPartialAccountEnvs) { | ||
throw new Error( | ||
'If you are providing one of you need to provide both: TEST_ACCOUNT_ADDRESS & TEST_ACCOUNT_PRIVATE_KEY' | ||
); | ||
} | ||
if (isDevnet) { | ||
// get account from devnet | ||
try { | ||
await this.fetchAccount(GS_DEFAULT_TEST_PROVIDER_URL); | ||
return true; | ||
} catch (error) { | ||
console.error('Fetching account from devnet failed'); | ||
} | ||
} else if (this.providedUrl) { | ||
// try to get it from remote devnet | ||
try { | ||
await this.fetchAccount(this.providedUrl); | ||
return true; | ||
} catch (error) { | ||
console.error(`Fetching account from provided url ${this.providedUrl} failed`); | ||
} | ||
} | ||
|
||
throw new Error( | ||
'Setting Account using all known strategies failed, provide basic test parameters' | ||
); | ||
} | ||
|
||
async execute(isDevnet: boolean): Promise<void> { | ||
const isAccountSet = await this.isAccountSet(isDevnet); | ||
if (isAccountSet) console.log('Detected Account'); | ||
} | ||
} | ||
|
||
export default new AccountResolver(); |
This file was deleted.
Oops, something went wrong.
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.