-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export const FUEL_GREEN = '#00f58c'; | ||
|
||
export const LOCAL_SERVER_URI = 'http://0.0.0.0:8080'; | ||
export const SERVER_URI = process.env.REACT_APP_LOCAL_SERVER | ||
? 'http://0.0.0.0:8080' | ||
? LOCAL_SERVER_URI | ||
: 'https://api.sway-playground.org'; |
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,65 @@ | ||
import { EXAMPLE_CONTRACTS } from '.'; | ||
import { LOCAL_SERVER_URI } from '../../../constants'; | ||
import { ExampleMenuItem } from '../components/ExampleDropdown'; | ||
|
||
describe(`test examples`, () => { | ||
beforeAll(() => { | ||
// Start server | ||
// require('../../../server'); | ||
}); | ||
|
||
describe(`transpile solidity examples`, () => { | ||
const uri = `${LOCAL_SERVER_URI}/transpile`; | ||
|
||
it.each( | ||
EXAMPLE_CONTRACTS['solidity'].map(({ label, code }: ExampleMenuItem) => [ | ||
label, | ||
code, | ||
]) | ||
)('%s', async (_label, code) => { | ||
// Call server | ||
const request = new Request(uri, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
contract: code, | ||
lanaguage: 'solidity', | ||
}), | ||
}); | ||
|
||
const response = await fetch(request); | ||
const {error, swayContract} = await response.json(); | ||
|
||
expect(error).toBeUndefined(); | ||
expect(swayContract).toContain('contract;'); | ||
}); | ||
}); | ||
|
||
describe(`compile sway examples`, () => { | ||
const uri = `${LOCAL_SERVER_URI}/compile`; | ||
|
||
it.each( | ||
EXAMPLE_CONTRACTS['sway'].map(({ label, code }: ExampleMenuItem) => [ | ||
label, | ||
code, | ||
]) | ||
)('%s', async (_label, code) => { | ||
// Call server | ||
const request = new Request(uri, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
contract: code, | ||
toolchain: 'latest' | ||
}), | ||
}); | ||
|
||
const response = await fetch(request); | ||
const { error, abi, bytecode, storageSlots, forcVersion } = await response.json(); | ||
|
||
expect(error).toBeUndefined(); | ||
expect(abi).toBeDefined(); | ||
expect(bytecode).toBeDefined(); | ||
expect(storageSlots).toBeDefined(); | ||
expect(forcVersion).toBeDefined(); | ||
}, 10000); | ||
}); | ||
}); |