-
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.
[NayNay] User Program Management::View Programs + Testing
- added new service file for view program pure function - added tests
- Loading branch information
Showing
9 changed files
with
66 additions
and
20 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
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,9 @@ | ||
import Entropy from "@entropyxyz/sdk"; | ||
|
||
export const verifyingKeyQuestion = (entropy: Entropy) => [{ | ||
type: 'list', | ||
name: 'verifyingKey', | ||
message: 'Select the key to proceeed', | ||
choices: entropy.keyring.accounts.registration.verifyingKeys, | ||
default: entropy.keyring.accounts.registration.verifyingKeys[0] | ||
}] |
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,11 @@ | ||
import { print } from "src/common/utils" | ||
|
||
export function displayPrograms (programs): void { | ||
programs.forEach((program, index) => { | ||
print( | ||
`${index + 1}. Pointer: ${ | ||
program.program_pointer | ||
}, Config: ${JSON.stringify(program.program_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 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,3 @@ | ||
export interface ViewProgramsParams { | ||
verifyingKey: string | ||
} |
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 @@ | ||
import Entropy from "@entropyxyz/sdk"; | ||
import { ViewProgramsParams } from "./types"; | ||
|
||
export async function viewPrograms (entropy: Entropy, { verifyingKey }: ViewProgramsParams): Promise<any[]> { | ||
return entropy.programs.get(verifyingKey) | ||
} |
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,15 @@ | ||
import test from 'tape' | ||
import { viewPrograms } from 'src/flows/user-program-management/view' | ||
import { charlieStashSeed, setupTest } from './testing-utils' | ||
|
||
const networkType = 'two-nodes' | ||
|
||
test('User Program Management::View Programs', async t => { | ||
const { run, entropy } = await setupTest(t, { seed: charlieStashSeed, networkType }) | ||
|
||
await run('charlie register', entropy.register()) | ||
const programs = await run('get charlie programs', viewPrograms(entropy, { verifyingKey: entropy.programs.verifyingKey })) | ||
|
||
t.equal(programs.length, 1, 'charlie has 1 program') | ||
t.end() | ||
}) |