-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* switches output of whitelist to a table as is standard for the cli also perhapse these columns headers are more understandable * add flags * add changeset * now test tables * update docs
- Loading branch information
Showing
5 changed files
with
169 additions
and
39 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,5 @@ | ||
--- | ||
'@celo/celocli': patch | ||
--- | ||
|
||
network:whitelist now oututs as a table, typical table formatting flags are now accepted such as --csv |
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,27 +1,85 @@ | ||
import { setupL2, testWithAnvil } from '@celo/dev-utils/lib/anvil-test' | ||
import { ux } from '@oclif/core' | ||
import Web3 from 'web3' | ||
import { testLocallyWithWeb3Node } from '../../test-utils/cliUtils' | ||
import { stripAnsiCodesFromNestedArray, testLocallyWithWeb3Node } from '../../test-utils/cliUtils' | ||
import Whitelist from './whitelist' | ||
|
||
process.env.NO_SYNCCHECK = 'true' | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
testWithAnvil('network:whitelist cmd', (web3: Web3) => { | ||
test('can print the whitelist', async () => { | ||
const spy = jest.spyOn(console, 'log') | ||
|
||
beforeEach(async () => { | ||
await setupL2(web3) | ||
}) | ||
|
||
const writeMock = jest.spyOn(ux.write, 'stdout') | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('can print the whitelist', async () => { | ||
await testLocallyWithWeb3Node(Whitelist, [], web3) | ||
|
||
expect(spy.mock.calls[0][0]).toMatchInlineSnapshot(` | ||
"Available currencies: | ||
0x0c6a0fde0A72bA3990870f0F99ED79a821703474 - Celo Euro (Celo Euro) - 18 decimals | ||
0x603931FF5E63d2fd3EEF1513a55fB773d8082195 - Celo Brazilian Real (Celo Brazilian Real) - 18 decimals | ||
0x82398F079D742F9D0Ae71ef8C99E5c68b2eD6705 - Celo Dollar (Celo Dollar) - 18 decimals" | ||
expect(stripAnsiCodesFromNestedArray(writeMock.mock.calls)).toMatchInlineSnapshot(` | ||
[ | ||
[ | ||
" Name Symbol Whitelisted Address Token Address Decimals Uses Adapter? | ||
", | ||
], | ||
[ | ||
" ─────────────────── ─────────────────── ────────────────────────────────────────── ────────────────────────────────────────── ──────── ───────────── | ||
", | ||
], | ||
[ | ||
" Celo Euro Celo Euro 0x0c6a0fde0A72bA3990870f0F99ED79a821703474 0x0c6a0fde0A72bA3990870f0F99ED79a821703474 18 false | ||
", | ||
], | ||
[ | ||
" Celo Brazilian Real Celo Brazilian Real 0x603931FF5E63d2fd3EEF1513a55fB773d8082195 0x603931FF5E63d2fd3EEF1513a55fB773d8082195 18 false | ||
", | ||
], | ||
[ | ||
" Celo Dollar Celo Dollar 0x82398F079D742F9D0Ae71ef8C99E5c68b2eD6705 0x82398F079D742F9D0Ae71ef8C99E5c68b2eD6705 18 false | ||
", | ||
], | ||
] | ||
`) | ||
}) | ||
it('modifies output when formating flag is passed', async () => { | ||
await testLocallyWithWeb3Node(Whitelist, ['--output=json'], web3) | ||
|
||
expect(writeMock.mock.calls).toMatchInlineSnapshot(` | ||
[ | ||
[ | ||
"[ | ||
{ | ||
"name": "Celo Euro", | ||
"symbol": "Celo Euro", | ||
"whitelisted": "0x0c6a0fde0A72bA3990870f0F99ED79a821703474", | ||
"token": "0x0c6a0fde0A72bA3990870f0F99ED79a821703474", | ||
"decimals": "18", | ||
"usesAdapter": "false" | ||
}, | ||
{ | ||
"name": "Celo Brazilian Real", | ||
"symbol": "Celo Brazilian Real", | ||
"whitelisted": "0x603931FF5E63d2fd3EEF1513a55fB773d8082195", | ||
"token": "0x603931FF5E63d2fd3EEF1513a55fB773d8082195", | ||
"decimals": "18", | ||
"usesAdapter": "false" | ||
}, | ||
{ | ||
"name": "Celo Dollar", | ||
"symbol": "Celo Dollar", | ||
"whitelisted": "0x82398F079D742F9D0Ae71ef8C99E5c68b2eD6705", | ||
"token": "0x82398F079D742F9D0Ae71ef8C99E5c68b2eD6705", | ||
"decimals": "18", | ||
"usesAdapter": "false" | ||
} | ||
] | ||
", | ||
], | ||
] | ||
`) | ||
}) | ||
}) |
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