-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updated to latest image * Updated to 1.7.0 rc5 tag * Fix mining test * Initial setup * Updated test * Updated EunosHeight in RegTest container * Added override pair * Tests passing, added docs * Increased code coverage * Add `blockchain.getBlockStats`, `blockchain.getBestBlockHash` RPC (#256) * getBlockStats, getBestBlockHash RCP implementation * Fixed and implemented requested changes. * Fixed requested changes * Minor fixes * Changed assertion to toStricEquals, additional test for getblockstats * Update packages/jellyfish-api-core/src/category/blockchain.ts Co-authored-by: Fuxing Loh <[email protected]> * Update packages/jellyfish-api-core/__tests__/category/blockchain.test.ts Co-authored-by: Fuxing Loh <[email protected]> * Update packages/jellyfish-api-core/src/category/blockchain.ts Co-authored-by: Fuxing Loh <[email protected]> * Additional test cases for getBlockStats * Minor fixes * Update blockchain.md * Minor fixes * Update blockchain.md Co-authored-by: Fuxing Loh <[email protected]> * Added remove oracle and tests * Fix test * Tidy test * Apply suggestions from code review Co-authored-by: Fuxing Loh <[email protected]> Co-authored-by: Fuxing Loh <[email protected]> Co-authored-by: Suraj Auwal <[email protected]> Co-authored-by: Fuxing Loh <[email protected]>
- Loading branch information
1 parent
8424ed8
commit 0302ad2
Showing
4 changed files
with
111 additions
and
17 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
74 changes: 74 additions & 0 deletions
74
packages/jellyfish-transaction-builder/__tests__/txn/txn_builder_remove_oracle.test.ts
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,74 @@ | ||
import { MasterNodeRegTestContainer, GenesisKeys } from '@defichain/testcontainers' | ||
import { getProviders, MockProviders } from '../provider.mock' | ||
import { P2WPKHTransactionBuilder } from '../../src' | ||
import { calculateTxid, fundEllipticPair, sendTransaction } from '../test.utils' | ||
import { WIF } from '@defichain/jellyfish-crypto' | ||
|
||
const container = new MasterNodeRegTestContainer() | ||
let providers: MockProviders | ||
let builder: P2WPKHTransactionBuilder | ||
|
||
beforeAll(async () => { | ||
await container.start() | ||
await container.waitForReady() | ||
await container.waitForWalletCoinbaseMaturity() | ||
|
||
providers = await getProviders(container) | ||
providers.setEllipticPair(WIF.asEllipticPair(GenesisKeys[GenesisKeys.length - 1].owner.privKey)) | ||
builder = new P2WPKHTransactionBuilder(providers.fee, providers.prevout, providers.elliptic) | ||
|
||
// Prep 1000 DFI Token for testing | ||
await container.waitForWalletBalanceGTE(1001) | ||
}) | ||
|
||
afterAll(async () => { | ||
await container.stop() | ||
}) | ||
|
||
describe('remove oracle', () => { | ||
beforeEach(async () => { | ||
await container.waitForWalletBalanceGTE(1) | ||
}) | ||
|
||
it('should appoint and then remove oracle', async () => { | ||
// Fund 10 DFI UTXO | ||
await fundEllipticPair(container, providers.ellipticPair, 10) | ||
await providers.setupMocks() // required to move utxos | ||
|
||
// Appoint Oracle | ||
const script = await providers.elliptic.script() | ||
const appointTxn = await builder.oracles.appointOracle({ | ||
script: script, | ||
weightage: 1, | ||
priceFeeds: [ | ||
{ | ||
token: 'TEST', | ||
currency: 'USD' | ||
} | ||
] | ||
}, script) | ||
|
||
const txid = calculateTxid(appointTxn) | ||
await sendTransaction(container, appointTxn) | ||
|
||
// Remove Oracle | ||
const removeTxn = await builder.oracles.removeOracle({ | ||
oracleId: txid | ||
}, script) | ||
|
||
// Ensure the created txn is correct. | ||
const outs = await sendTransaction(container, removeTxn) | ||
expect(outs[0].value).toStrictEqual(0) | ||
expect(outs[1].value).toBeLessThan(10) | ||
expect(outs[1].value).toBeGreaterThan(9.999) | ||
expect(outs[1].scriptPubKey.addresses[0]).toStrictEqual(await providers.getAddress()) | ||
|
||
// Ensure you don't send all your balance away during appoint oracle | ||
const prevouts = await providers.prevout.all() | ||
expect(prevouts.length).toStrictEqual(1) | ||
expect(prevouts[0].value.toNumber()).toBeLessThan(10) | ||
expect(prevouts[0].value.toNumber()).toBeGreaterThan(9.999) | ||
}) | ||
}) | ||
|
||
// TODO(monstrobishi): test account state once RPC calls are in place |
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