-
Notifications
You must be signed in to change notification settings - Fork 0
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
[NayNay] Updating faucet amount #258
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ export const FAUCET_PROGRAM_MOD_KEY = '5GWamxgW4XWcwGsrUynqnFq2oNZPqNXQhMDfgNH9x | |
// this is differnt from tests because the fauce that is live now was lazily deployed without schemas | ||
// TO-DO: update this when faucet is deployed properly | ||
export const TESTNET_PROGRAM_HASH = '0x12af0bd1f2d91f12e34aeb07ea622c315dbc3c2bdc1e25ff98c23f1e61106c77' | ||
// Hash with max send of 1e10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💛 |
||
export const LOCAL_PROGRAM_HASH = '0x5fa0536818acaa380b0c349c8e887bf269d593a47e30c8e31de53a75d327f7b1' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,18 @@ import { EntropyFaucet } from '../src/faucet/main' | |
import { LOCAL_PROGRAM_HASH } from '../src/faucet/utils' | ||
import { EntropyAccount } from '../src/account/main' | ||
|
||
test('Faucet Tests', async t => { | ||
async function setupAndFundFaucet (t, naynayEntropy) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this function into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do this in a different pr though i'll merge this in now |
||
const { run, entropy, endpoint } = await setupTest(t, { seed: charlieStashSeed }) | ||
const { entropy: naynayEntropy } = await setupTest(t) | ||
|
||
const balanceService = new EntropyBalance(entropy, endpoint) | ||
const accountService = new EntropyAccount(entropy, endpoint) | ||
const transferService = new EntropyTransfer(entropy, endpoint) | ||
const faucetService = new EntropyFaucet(naynayEntropy, endpoint) | ||
const accountService = new EntropyAccount(entropy, endpoint) | ||
|
||
const faucetProgram = readFileSync('tests/programs/faucet_program.wasm') | ||
|
||
const genesisHash = await entropy.substrate.rpc.chain.getBlockHash(0) | ||
|
||
const userConfig = { | ||
max_transfer_amount: 10_000_000_000, | ||
max_transfer_amount: 20_000_000_000, | ||
genesis_hash: stripHexPrefix(genesisHash.toString()) | ||
} | ||
const configurationSchema = { | ||
|
@@ -41,11 +38,7 @@ test('Faucet Tests', async t => { | |
|
||
// Confirm faucetPointer matches deployed program pointer | ||
t.equal(faucetProgramPointer, LOCAL_PROGRAM_HASH, 'Program pointer matches') | ||
let entropyBalance = await balanceService.getBalance(entropy.keyring.accounts.registration.address) | ||
console.log('Balance Charlie::', entropyBalance); | ||
|
||
let naynayBalance = await balanceService.getBalance(naynayEntropy.keyring.accounts.registration.address) | ||
t.equal(naynayBalance, 0, 'Naynay is broke af') | ||
|
||
// register with faucet program | ||
await run('Register Faucet Program for charlie stash', accountService.register( | ||
{ | ||
|
@@ -57,29 +50,89 @@ test('Faucet Tests', async t => { | |
// @ts-expect-error | ||
const { chosenVerifyingKey, faucetAddress } = faucetService.getRandomFaucet([], verifyingKeys) | ||
// adding funds to faucet address | ||
entropyBalance = await balanceService.getBalance(entropy.keyring.accounts.registration.address) | ||
const faucetAddressBalance = await balanceService.getBalance(faucetAddress) | ||
console.log('Balance faucetAddress::', faucetAddressBalance); | ||
console.log('Balance charlie 2::', entropyBalance); | ||
|
||
|
||
await run('Transfer funds to faucet address', transferService.transfer(faucetAddress, "1000")) | ||
|
||
const transferStatus = await faucetService.sendMoney( | ||
return { faucetProgramPointer, chosenVerifyingKey, faucetAddress } | ||
} | ||
|
||
test('Faucet Tests: Successfully send funds and register', async t => { | ||
const { run, endpoint, entropy: naynayEntropy } = await setupTest(t) | ||
|
||
const faucetService = new EntropyFaucet(naynayEntropy, endpoint) | ||
const balanceService = new EntropyBalance(naynayEntropy, endpoint) | ||
|
||
const { faucetAddress, chosenVerifyingKey, faucetProgramPointer } = await setupAndFundFaucet(t, naynayEntropy) | ||
|
||
let naynayBalance = await balanceService.getBalance(naynayEntropy.keyring.accounts.registration.address) | ||
t.equal(naynayBalance, 0, 'Naynay is broke af') | ||
|
||
const transferStatus = await run('Sending faucet funds to account', faucetService.sendMoney( | ||
{ | ||
amount: "10000000000", | ||
amount: "20000000000", | ||
addressToSendTo: naynayEntropy.keyring.accounts.registration.address, | ||
faucetAddress, | ||
chosenVerifyingKey, | ||
faucetProgramPointer | ||
} | ||
) | ||
)) | ||
|
||
t.ok(transferStatus.isFinalized, 'Transfer is good') | ||
|
||
naynayBalance = await balanceService.getBalance(naynayEntropy.keyring.accounts.registration.address) | ||
|
||
t.ok(naynayBalance > 0, 'Naynay is drippin in faucet tokens') | ||
|
||
// Test if user can register after receiving funds | ||
const naynayAccountService = new EntropyAccount(naynayEntropy, endpoint) | ||
const verifyingKey = await run('register account', naynayAccountService.register()) | ||
|
||
t.ok(!!verifyingKey, 'Verifying key exists and is returned from register method') | ||
|
||
const fullAccount = naynayEntropy.keyring.getAccount() | ||
t.equal(verifyingKey, fullAccount?.registration?.verifyingKeys?.[0], 'verifying key matches key added to registration account') | ||
|
||
t.end() | ||
}) | ||
|
||
// TODO: @naynay fix below test for register failing when only sending 1e10 bits | ||
// test('Faucet Tests: Successfully send funds but cannot register', async t => { | ||
Comment on lines
+97
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this also be an issue? |
||
// const { run, endpoint, entropy: naynayEntropy } = await setupTest(t) | ||
|
||
// const faucetService = new EntropyFaucet(naynayEntropy, endpoint) | ||
// const balanceService = new EntropyBalance(naynayEntropy, endpoint) | ||
|
||
// const { faucetAddress, chosenVerifyingKey, faucetProgramPointer } = await setupAndFundFaucet(t, naynayEntropy) | ||
|
||
// let naynayBalance = await balanceService.getBalance(naynayEntropy.keyring.accounts.registration.address) | ||
// t.equal(naynayBalance, 0, 'Naynay is broke af') | ||
|
||
// const transferStatus = await run('Sending faucet funds to account', faucetService.sendMoney( | ||
// { | ||
// amount: "10000000000", | ||
// addressToSendTo: naynayEntropy.keyring.accounts.registration.address, | ||
// faucetAddress, | ||
// chosenVerifyingKey, | ||
// faucetProgramPointer | ||
// } | ||
// )) | ||
|
||
// t.ok(transferStatus.isFinalized, 'Transfer is good') | ||
|
||
// naynayBalance = await balanceService.getBalance(naynayEntropy.keyring.accounts.registration.address) | ||
|
||
// t.ok(naynayBalance > 0, 'Naynay is drippin in faucet tokens') | ||
|
||
// // Test if user can register after receiving funds | ||
// const naynayAccountService = new EntropyAccount(naynayEntropy, endpoint) | ||
// try { | ||
// const verifyingKey = await naynayAccountService.register() | ||
// console.log('ver key', verifyingKey); | ||
|
||
// // t.fail('Register should fail') | ||
// } catch (error) { | ||
// console.log('error', error); | ||
|
||
// t.pass('Regsitration failed') | ||
// t.end() | ||
// } | ||
// }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job writing docs!