forked from sphinx-labs/sphinx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pg): update init tasks and add tests for TypeScript init tasks
- Loading branch information
1 parent
d6bb68c
commit f0bb035
Showing
18 changed files
with
334 additions
and
272 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@chugsplash/plugins': patch | ||
'@chugsplash/demo': patch | ||
--- | ||
|
||
Update init tasks and add tests for TypeScript init tasks |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
[profile.default] | ||
src = 'contracts' | ||
ffi = true | ||
build_info = true | ||
extra_output = ['storageLayout', 'evm.gasEstimates'] | ||
fs_permissions = [{ access = "read", path = "/"}] | ||
allow_paths = ["../.."] | ||
|
||
remappings=[ | ||
'@chugsplash/plugins=../../node_modules/@chugsplash/plugins/contracts/foundry', | ||
'@chugsplash/contracts=node_modules/@chugsplash/contracts/', | ||
'forge-std/=node_modules/forge-std/src/', | ||
'ds-test/=node_modules/ds-test/src/' | ||
] | ||
|
||
[rpc_endpoints] | ||
anvil = "http://127.0.0.1:8545" |
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 |
---|---|---|
|
@@ -53,6 +53,9 @@ const config: HardhatUserConfig = { | |
accounts, | ||
}, | ||
}, | ||
mocha: { | ||
timeout: 100_000, | ||
}, | ||
} | ||
|
||
export default config |
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 was deleted.
Oops, something went wrong.
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,99 @@ | ||
import * as fs from 'fs' | ||
import path from 'path' | ||
|
||
import { execAsync } from '@chugsplash/core' | ||
import { | ||
foundryTestFileName, | ||
foundryScriptFileName, | ||
sampleContractFileName, | ||
sampleConfigFileNameTypeScript, | ||
hhTestFileNameTypeScript, | ||
} from '@chugsplash/plugins' | ||
import { expect } from 'chai' | ||
|
||
const configDirPath = 'chugsplash' | ||
|
||
describe('Init Task', () => { | ||
let configPath: string | ||
let contractPath: string | ||
let foundryTestPath: string | ||
let foundryScriptPath: string | ||
let hardhatTestPath: string | ||
before(async () => { | ||
const forgeConfigOutput = await execAsync('forge config --json') | ||
const forgeConfig = JSON.parse(forgeConfigOutput.stdout) | ||
const { src, test, script } = forgeConfig | ||
|
||
configPath = path.join(configDirPath, sampleConfigFileNameTypeScript) | ||
contractPath = path.join(src, sampleContractFileName) | ||
foundryTestPath = path.join(test, foundryTestFileName) | ||
foundryScriptPath = path.join(script, foundryScriptFileName) | ||
|
||
hardhatTestPath = path.join(test, hhTestFileNameTypeScript) | ||
}) | ||
|
||
afterEach(async () => { | ||
// Delete all of the generated files | ||
|
||
fs.rmSync(configPath) | ||
fs.rmSync(contractPath) | ||
|
||
if (fs.existsSync(foundryTestPath)) { | ||
fs.rmSync(foundryTestPath) | ||
} | ||
|
||
if (fs.existsSync(foundryScriptPath)) { | ||
fs.rmSync(foundryScriptPath) | ||
} | ||
|
||
if (fs.existsSync(hardhatTestPath)) { | ||
fs.rmSync(hardhatTestPath) | ||
} | ||
}) | ||
|
||
it('Succeeds for a sample Foundry project with a TypeScript config', async () => { | ||
// Check that the sample files haven't been created yet | ||
expect(fs.existsSync(configPath)).to.be.false | ||
expect(fs.existsSync(contractPath)).to.be.false | ||
expect(fs.existsSync(foundryTestPath)).to.be.false | ||
expect(fs.existsSync(foundryScriptPath)).to.be.false | ||
|
||
await execAsync('npx chugsplash init --ts') | ||
|
||
// Check that the files have been created | ||
expect(fs.existsSync(configPath)).to.be.true | ||
expect(fs.existsSync(contractPath)).to.be.true | ||
expect(fs.existsSync(foundryTestPath)).to.be.true | ||
expect(fs.existsSync(foundryScriptPath)).to.be.true | ||
|
||
// Next, we'll run the test and script files. If a Foundry test case fails, or if there's some | ||
// other error that occurs when running either command, this test case will also fail. | ||
await execAsync(`forge test --match-path ${foundryTestPath}`) | ||
await execAsync(`forge script ${foundryScriptPath}`) | ||
}) | ||
|
||
it('Succeeds for a sample Hardhat project with a TypeScript config', async () => { | ||
// Check that the sample files haven't been created yet | ||
expect(fs.existsSync(configPath)).to.be.false | ||
expect(fs.existsSync(contractPath)).to.be.false | ||
expect(fs.existsSync(hardhatTestPath)).to.be.false | ||
|
||
// This command infers that we're using a TypeScript project based on the fact that we have a | ||
// hardhat.config.ts (instead of .js). | ||
await execAsync('npx hardhat chugsplash-init') | ||
|
||
// Check that the files have been created | ||
expect(fs.existsSync(configPath)).to.be.true | ||
expect(fs.existsSync(contractPath)).to.be.true | ||
expect(fs.existsSync(hardhatTestPath)).to.be.true | ||
|
||
// Next, we'll run the test and script files. If a Hardhat test case fails, or if there's some | ||
// other error that occurs when running either command, this test case will also fail. | ||
await execAsync( | ||
`npx hardhat test ${hardhatTestPath} --config-path ${configPath} --project MyFirstProject --use-default-signer` | ||
) | ||
await execAsync( | ||
`npx hardhat chugsplash-deploy --config-path ${configPath} --project MyFirstProject --use-default-signer` | ||
) | ||
}) | ||
}) |
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.