Skip to content
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

Internal Audit #1

Open
wants to merge 197 commits into
base: empty
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
e861edb
First commit containing code for monitoring & middleware for testing
jacquesvcritien Nov 17, 2022
12d7d84
Fixed accept oracle script + added grafana dashboard
jacquesvcritien Nov 17, 2022
3b85427
Added oracle name to monitoring
jacquesvcritien Nov 17, 2022
f5d6c2f
Added more docs regarding oracles.json file
jacquesvcritien Nov 18, 2022
8553f74
Fixed typo
jacquesvcritien Nov 18, 2022
83c5e79
Forced price submission for timer requests
jacquesvcritien Nov 18, 2022
028daf5
Merge branch 'master' of https://github.com/jacquesvcritien/agoric-cl…
jacquesvcritien Nov 18, 2022
5029f9d
Fixed monitoring script
jacquesvcritien Nov 22, 2022
0b530db
Cleaned code and added documentation
jacquesvcritien Dec 5, 2022
8d487c0
Cleaned code & added documentation
jacquesvcritien Dec 5, 2022
22b5d3f
Fixed small issues with new clean code
jacquesvcritien Dec 6, 2022
03fc00f
Added the following:
jacquesvcritien Jan 5, 2023
60fa5df
Updated variable names
jacquesvcritien Jan 5, 2023
9d93831
Fixed more variables
jacquesvcritien Jan 5, 2023
5b7f94d
Added some changes to the monitorinf script which reflect the latest …
jacquesvcritien Jan 5, 2023
5076931
changes to use numWantsSatisfied
jacquesvcritien Jan 12, 2023
7132e34
Added last job submission time to state and changed to check errors
jacquesvcritien Jan 12, 2023
18c55c0
Fixed monitoring & updated dashboard
jacquesvcritien Jan 12, 2023
61b3f74
Added script to provision wallet
jacquesvcritien Jan 16, 2023
981cce9
Optimising middleware and monitoring script
jacquesvcritien Jan 19, 2023
ce1b7e4
Reducing gas consumption
jacquesvcritien Jan 19, 2023
1b71181
Avoiding old round submissions
jacquesvcritien Jan 20, 2023
dcde3d2
Added reply to the CL node without waiting for the price push
jacquesvcritien Jan 20, 2023
b94e758
Making price pushes more efficient
jacquesvcritien Jan 20, 2023
36ee050
Increasing pushing interval to 10m
jacquesvcritien Jan 21, 2023
8daa778
Fixing middleware with issue for startedAt
jacquesvcritien Jan 21, 2023
b4d69e9
Fixing issue with middleware
jacquesvcritien Jan 21, 2023
3edd26e
Removed unwanted files
jacquesvcritien Jan 22, 2023
02c4e5f
Readd monitor scrpi
jacquesvcritien Jan 24, 2023
7f006bf
Change folder name
jacquesvcritien Jan 24, 2023
353b3a9
Update documentation
jacquesvcritien Jan 24, 2023
f90f087
Updated documentation
jacquesvcritien Jan 24, 2023
3a956f9
Removed unwanted line
jacquesvcritien Jan 24, 2023
4e1f7ec
Removed unused function
jacquesvcritien Jan 24, 2023
f4e3f2d
Updated documentation
jacquesvcritien Jan 24, 2023
a1930f0
Documentation update
jacquesvcritien Jan 24, 2023
0c2c891
Updated documentation
jacquesvcritien Jan 25, 2023
5d1c4cc
Cleaning code
jacquesvcritien Jan 25, 2023
5776fb4
Small update to pointer
jacquesvcritien Jan 26, 2023
d4e1c20
Getting rid of exiters
jacquesvcritien Jan 26, 2023
8a3670c
Updated documentation to reflect last commit's changes
jacquesvcritien Jan 26, 2023
2e2d3e0
Removing global env vars for poll, push intervals, decimal places and…
jacquesvcritien Jan 26, 2023
3ca7280
Fixing entry script for monitoring
jacquesvcritien Jan 26, 2023
1983889
Fixed path for feeds file
jacquesvcritien Jan 26, 2023
aa3e56b
Updated documentation
jacquesvcritien Jan 26, 2023
80bc727
Updating accept oracle invitation script
jacquesvcritien Jan 27, 2023
9d1a956
Updating middleware to avoid using offers file
jacquesvcritien Jan 27, 2023
7ba566f
Updated documentation to remove OFFERS_FILE
jacquesvcritien Jan 27, 2023
805c217
Updated toc
jacquesvcritien Jan 27, 2023
f635a39
Increasing poll interval to 3m
jacquesvcritien Jan 28, 2023
d18f7ee
Fixing startup issue
jacquesvcritien Feb 6, 2023
6a7d5a0
Added price update condition
jacquesvcritien Feb 6, 2023
ac87a0f
Trying to fix middlewre offers issue
jacquesvcritien Feb 6, 2023
6f9fc0f
Added change for offers to monitor
jacquesvcritien Feb 6, 2023
627388b
Fixing issue with monitoring script
jacquesvcritien Feb 6, 2023
fa27d53
Fixing issue with monitoring script
jacquesvcritien Feb 6, 2023
9e3c0d6
Fixed some typos
jacquesvcritien Feb 14, 2023
57e20c2
Merge branch 'master' into full_review
Feb 15, 2023
ca6a76d
Added tests, fixed small issue with getOffers, updated docs and added…
jacquesvcritien Feb 16, 2023
c4427c2
Updated modules for tests
jacquesvcritien Feb 16, 2023
91b72a3
Merge pull request #2 from jacquesvcritien/master
jacquesvcritien Feb 16, 2023
47346bd
Moved to sqllite DB from JSON state file + Updated docs, tests.
jacquesvcritien Feb 21, 2023
e594b39
Fixed typos and added line width
jacquesvcritien Feb 21, 2023
195cc08
Added builds to docker-compose file
jacquesvcritien Feb 21, 2023
786f629
Updated read me for docker-compose change
jacquesvcritien Feb 22, 2023
276d72d
Merge pull request #3 from jacquesvcritien/master
jacquesvcritien Feb 22, 2023
e7d6c89
Adding 80 character line limit
jacquesvcritien Feb 22, 2023
707949b
Removed .DS_Store and added it to gitignore
jacquesvcritien Feb 22, 2023
75621d3
Refactored code and split functions into helper functions
jacquesvcritien Feb 22, 2023
a6326b8
Removed useless print
jacquesvcritien Feb 22, 2023
cd76729
Fixed documentation typos and grammatical errors
jacquesvcritien Feb 22, 2023
eedaed1
Changed to docker-compose commands
jacquesvcritien Feb 22, 2023
b0e6e4b
Updated docs for consistency
jacquesvcritien Feb 22, 2023
d618962
Rewording in docs
jacquesvcritien Feb 22, 2023
2220ec8
Moved feeds.json to config folder
jacquesvcritien Feb 22, 2023
dcfe378
Moved feeds file to config folder
jacquesvcritien Feb 22, 2023
978a034
Fixed small typo
jacquesvcritien Feb 22, 2023
22a2462
Moved imports before mocking
jacquesvcritien Feb 22, 2023
2783150
Merge pull request #4 from jacquesvcritien/master
jacquesvcritien Feb 22, 2023
ef14bde
Added all env vars to docker-compose and rename feeds.json to feeds-c…
jacquesvcritien Feb 22, 2023
c6b21b3
Updated description in package.json
jacquesvcritien Feb 22, 2023
0a0d06b
Lowered job request timeout to 5s
jacquesvcritien Feb 22, 2023
aa7bbc4
Changed failover price to -1
jacquesvcritien Feb 22, 2023
d342e64
Removed extra comment
jacquesvcritien Feb 22, 2023
131718b
Removed .vscode from git
jacquesvcritien Feb 22, 2023
670ac02
Fixed for line width
jacquesvcritien Feb 22, 2023
2a7bc45
Formatted tests for 80 line width
jacquesvcritien Feb 22, 2023
d85360c
Documentation updates
jacquesvcritien Feb 22, 2023
ad4d3cb
Changed != to !== and == to ===
jacquesvcritien Feb 22, 2023
5811039
Cleaned util code
jacquesvcritien Feb 22, 2023
d2ad409
Changed all var to let
jacquesvcritien Feb 22, 2023
e6e00fe
Changing lastVisited to -1 to avoid possible issue with id 0
jacquesvcritien Feb 22, 2023
8db3abf
Cleaned code for line width
jacquesvcritien Feb 22, 2023
c97d578
Updated comments to include space and starting letter as capital
jacquesvcritien Feb 22, 2023
4d59ffa
Merge pull request #5 from jacquesvcritien/master
jacquesvcritien Feb 22, 2023
87abd4f
Removed extra code
jacquesvcritien Feb 22, 2023
1ba5446
Added a fix to the monitoring script
jacquesvcritien Feb 23, 2023
f9432cb
Fixed some indentation
jacquesvcritien Feb 23, 2023
b428c13
Fixed docker service for monitor
jacquesvcritien Feb 23, 2023
138c431
Removing counter and using history.length
jacquesvcritien Feb 23, 2023
f060346
Fixed typos in docs
jacquesvcritien Feb 23, 2023
07cae21
Fixed else if indentation
jacquesvcritien Feb 23, 2023
e3ae942
Changed wording in docs
jacquesvcritien Feb 23, 2023
8a77991
Fixed example in docs
jacquesvcritien Feb 23, 2023
e4c3b49
Combined condition
jacquesvcritien Feb 23, 2023
71bb622
Updated comment
jacquesvcritien Feb 23, 2023
e9a33da
Separated function which checks whether a price push update should be…
jacquesvcritien Feb 23, 2023
1881ba6
Fixing issue with new utils function
jacquesvcritien Feb 23, 2023
e16864f
Split condition
jacquesvcritien Feb 23, 2023
6248090
Broke down condition
jacquesvcritien Feb 23, 2023
a18a2ee
Removing extra line setting the id for the offer
jacquesvcritien Feb 23, 2023
a534c54
Removed extra line in monitoring
jacquesvcritien Feb 23, 2023
eaa7011
Removed any ts comments
jacquesvcritien Feb 23, 2023
e9bf66d
Removed ts comments part 2
jacquesvcritien Feb 23, 2023
3772c9e
Changed to foreach
jacquesvcritien Feb 23, 2023
de8807b
Fixed function comment
jacquesvcritien Feb 23, 2023
e91055d
Fixed docs
jacquesvcritien Feb 23, 2023
cf641ec
Fixed comment
jacquesvcritien Feb 23, 2023
4fc5833
Calling getOraclesInvitations() on every interval in monitor
jacquesvcritien Feb 23, 2023
327efae
Removed extra print
jacquesvcritien Feb 23, 2023
9c07061
Fixed some formatting in monitor
jacquesvcritien Feb 23, 2023
488fb2f
Changed to oracleLastEpoch for consistency
jacquesvcritien Feb 23, 2023
07a9328
Fixed test comment to match standard
jacquesvcritien Feb 23, 2023
7b9b88c
Reverted offers foreach
jacquesvcritien Feb 23, 2023
6bd4755
Refactored controller and bridge
jacquesvcritien Feb 23, 2023
9972147
Fixed package name
jacquesvcritien Feb 23, 2023
9d49fe1
Fixed condition for /adapter
jacquesvcritien Feb 23, 2023
2a70a72
Added some more comments
jacquesvcritien Feb 23, 2023
5408f18
Updated spacing
jacquesvcritien Feb 23, 2023
00e2e01
Updated more spacing
jacquesvcritien Feb 23, 2023
3c8d4af
Fixed formatting
jacquesvcritien Feb 23, 2023
9f027c8
Fixed comments indentation
jacquesvcritien Feb 23, 2023
dd01cbd
Added more spacing
jacquesvcritien Feb 23, 2023
1068142
Fixed line limit for comment
jacquesvcritien Feb 23, 2023
bab17ac
Added space in monitor
jacquesvcritien Feb 23, 2023
54132c2
Cleaned line in monitor
jacquesvcritien Feb 23, 2023
66a78fb
Updated docs
jacquesvcritien Feb 23, 2023
4c5dd9c
Removed two unused scripts
jacquesvcritien Feb 23, 2023
707addb
Added link to setup-docs
jacquesvcritien Feb 23, 2023
70bc917
Updated docs
jacquesvcritien Feb 23, 2023
822e961
Fixing comment
jacquesvcritien Feb 23, 2023
42dc406
Added examples for feed and jobName
jacquesvcritien Feb 23, 2023
cd710e1
Added vstorage explanation
jacquesvcritien Feb 23, 2023
653447f
Fixed console print
jacquesvcritien Feb 23, 2023
78b48d4
Creating a class for the middleware env vars
jacquesvcritien Feb 23, 2023
82aea45
Fixing middlewareEnv
jacquesvcritien Feb 23, 2023
47af31f
Fixing env var classes
jacquesvcritien Feb 23, 2023
6e5ed8b
Added block interval to middleware env vars
jacquesvcritien Feb 23, 2023
fdffab7
Added checks for numbers
jacquesvcritien Feb 23, 2023
3efa2ed
Changed != to !== in env var classes
jacquesvcritien Feb 23, 2023
670217e
Fixed comment in monitor
jacquesvcritien Feb 23, 2023
4ac2d76
Removing FEEDS_FILE from an env var
jacquesvcritien Feb 23, 2023
2c22ec9
Wrapped endpoints in try catches
jacquesvcritien Feb 24, 2023
6903cb6
Moved to winston logger
jacquesvcritien Feb 24, 2023
5e00308
Changed log commas to +
jacquesvcritien Feb 24, 2023
e4354ea
Removed extra JSON parsing
jacquesvcritien Feb 24, 2023
2bc26d5
Adding validation for feed invitation
jacquesvcritien Feb 24, 2023
a3baaa8
Added try catches for capdata parsing
jacquesvcritien Feb 24, 2023
2c23f76
Wrapped db functions in try catches
jacquesvcritien Feb 24, 2023
0634fe7
Added check for jobname
jacquesvcritien Feb 24, 2023
049494e
Removed catches from updateTable
jacquesvcritien Feb 24, 2023
ad863b5
Removed extra catches
jacquesvcritien Feb 24, 2023
0e14b95
Changed name for uppercase to temp
jacquesvcritien Feb 24, 2023
0d858dd
Renamed Env class files
jacquesvcritien Feb 24, 2023
5467000
Fixed small thing in test
jacquesvcritien Feb 24, 2023
a9027ca
Added oracle parameter to getOraclesInvitations
jacquesvcritien Feb 24, 2023
df3e68e
Removed unused import
jacquesvcritien Feb 24, 2023
ec0c342
Fixed issue related to getOraclesInvitations
jacquesvcritien Feb 24, 2023
9899126
Added some formatting changes to chain.js
jacquesvcritien Feb 24, 2023
bafa574
Changes to modularise the monitoring script
jacquesvcritien Feb 24, 2023
3a916f2
Created config classes
jacquesvcritien Feb 24, 2023
56be0c2
Fixed small import
jacquesvcritien Feb 24, 2023
a292d52
Imported feeds config
jacquesvcritien Feb 24, 2023
bc2d6ee
Fixing issue with feedsconfig
jacquesvcritien Feb 24, 2023
f622fd6
Fixed another issue with feeds
jacquesvcritien Feb 24, 2023
c24989f
Added db migrations
jacquesvcritien Feb 24, 2023
00e4382
Fixed second migration
jacquesvcritien Feb 24, 2023
c683c7a
Fixed db functions to match new package
jacquesvcritien Feb 24, 2023
40f68e5
Updated second migration
jacquesvcritien Feb 24, 2023
de65db1
Changed round details to a class
jacquesvcritien Feb 24, 2023
5166612
Merge pull request #6 from jacquesvcritien/master
jacquesvcritien Feb 25, 2023
0f2d4ec
Removed unused imports
jacquesvcritien Feb 27, 2023
a64393c
Changed env classes to singletons + removed some unused imports
jacquesvcritien Feb 27, 2023
dfbb9c0
Fixing import
jacquesvcritien Feb 27, 2023
b95e541
Importing monitorEnvInstance for monitor.js
jacquesvcritien Feb 27, 2023
ec2df2c
Updated .env sample
jacquesvcritien Feb 27, 2023
317321c
Changed filenames
jacquesvcritien Feb 27, 2023
5875788
Updated credentials filename
jacquesvcritien Feb 27, 2023
e2df618
Reverting env sample changes
jacquesvcritien Feb 27, 2023
268caad
Cosmetic changes
jacquesvcritien Feb 27, 2023
9379c56
More cosmetic changes
jacquesvcritien Feb 27, 2023
29244ce
More minor fixes
jacquesvcritien Feb 27, 2023
672f0f1
Added poll_interval to docker-compose, added check for invitations va…
jacquesvcritien Feb 27, 2023
c332c3e
Merge pull request #8 from jacquesvcritien/master
jacquesvcritien Feb 27, 2023
eeb7e3d
Switched to template strings
jacquesvcritien Feb 27, 2023
0cff0c4
Fixing typo
jacquesvcritien Feb 27, 2023
d67b4f1
Merge pull request #9 from jacquesvcritien/master
jacquesvcritien Feb 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
dillu24 marked this conversation as resolved.
Show resolved Hide resolved
"cSpell.words": [
"UI",
"initialise",
"Agoric"
],
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 80,
"editor.wrappingIndent": "same"
}
26 changes: 26 additions & 0 deletions Dockerfile.middleware
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:16.17.1

RUN apt install g++
RUN apt install bash gcc openssl
RUN apt update && apt install ca-certificates wget
RUN wget -O go.tgz https://golang.org/dl/go1.19.2.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf go.tgz
ENV PATH "/usr/local/go/bin:$PATH"
ENV GOPATH "/opt/go/"
ENV PATH "$PATH:$GOPATH/bin"

WORKDIR /agoric
RUN git clone https://github.com/agoric/agoric-sdk
WORKDIR /agoric/agoric-sdk
RUN yarn install
RUN yarn build
RUN cd packages/cosmic-swingset && make
ENV PATH "$PATH:$HOME/bin"

WORKDIR /oracle-cl-middleware
COPY package.json package.json
RUN yarn install
COPY . .
WORKDIR /oracle-cl-middleware/src

CMD [ "./bin-middleware.js" ]
13 changes: 13 additions & 0 deletions Dockerfile.monitor
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16.17.1

WORKDIR /oracle-cl-middleware

COPY package.json package.json

RUN yarn install

COPY . .

WORKDIR /oracle-cl-middleware/src

CMD [ "./bin-monitor.js" ]
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Agoric Oracle Middleware

## Create oracles.json file

In order to monitor oracles, you need to create a file at <b>~/config/oracles.json</b>.
As can be seen below, it takes an array of oracles with their addresses and names.

```json
{
"agoric12345aaaaaaaaaa" : { "oracleName": "Oracle 1" },
"agoric678910bbbbbbbbb" : { "oracleName": "Oracle 2" }
}
```

## To run both the middleware and monitoring script

```bash
docker-compose up -d
```
dillu24 marked this conversation as resolved.
Show resolved Hide resolved
166 changes: 166 additions & 0 deletions __tests__/middleware-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
jest.mock('@agoric/casting', () => {
return {
iterateReverse: jest.fn(),
makeLeader: jest.fn(),
makeFollower: jest.fn(),
};
});

jest.mock('sqlite3', () => {
return {
Database: jest.fn(),
};
});

jest.mock('../src/lib/rpc.js', () => {
return {
boardSlottingMarshaller: jest.fn(),
networkConfig: { rpcAddrs: ["http://127.0.0.1:26657"], chainName: "agoriclocal" },
dillu24 marked this conversation as resolved.
Show resolved Hide resolved
makeAgoricNames: jest.fn()
};
});

jest.mock('../src/lib/wallet.js', () => {
return {
getCurrent: jest.fn(),
};
});

jest.mock('../src/helpers/utils.js', () => {
const originalModule = jest.requireActual("../src/helpers/utils.js")
return {
...originalModule,
readVStorage: jest.fn()
};
});

import { readJSONFile, readVStorage } from '../src/helpers/utils.js';
import { getOffers, checkSubmissionForRound, queryPrice, queryRound, getOraclesInvitations } from '../src/oracle/middleware';
jacquesvcritien marked this conversation as resolved.
Show resolved Hide resolved
import { iterateReverse, makeLeader, makeFollower } from '@agoric/casting';
import { boardSlottingMarshaller, makeAgoricNames } from '../src/lib/rpc.js'
import { getCurrent } from '../src/lib/wallet.js'
import sqlite3 from 'sqlite3';

let iterateReverseOutput = readJSONFile("__tests__/mock-objects/followerReversed.json")
jacquesvcritien marked this conversation as resolved.
Show resolved Hide resolved
let currentOutput = readJSONFile("__tests__/mock-objects/current.json")
let agoricNamesOutput = readJSONFile("__tests__/mock-objects/agoricNames.json")

const asyncIterator = {
[Symbol.asyncIterator]: function() {
let i = 0;
return {
next: () => {
return new Promise(resolve => {
if (i < iterateReverseOutput.length) {
resolve({ value: iterateReverseOutput[i++], done: false });
} else {
resolve({ done: true });
}
});
}
};
}
};

iterateReverse.mockReturnValue(asyncIterator)
makeLeader.mockReturnValue({})
makeFollower.mockReturnValue({})
boardSlottingMarshaller.mockReturnValue({})
getCurrent.mockReturnValue(currentOutput)
makeAgoricNames.mockReturnValue(agoricNamesOutput)
sqlite3.Database.mockReturnValue({})

/**
* Test for get offers
*/
test('calls getOffers to get latest successful submissions', async () => {

const offers = await getOffers({});

//notice how only the first offer should be calculated because for every offer there will be 3 entries
dillu24 marked this conversation as resolved.
Show resolved Hide resolved
expect(offers).toStrictEqual(
[
{
"status": {
"id": 1676450914983,
"invitationSpec": {
"invitationArgs": [
{
"roundId": 735,
"unitPrice": "13312851"
}
],
"invitationMakerName": "PushPrice",
"previousOffer": 1675687989744,
"source": "continuing"
},
"numWantsSatisfied": 1,
"payouts": {},
"proposal": {}
},
"updated": "offerStatus"
}
]
);
});

/**
* Test for check submission - with submission
*/
test('calls checkSubmissionForRound to check if there was a submission for round with submission', async () => {
dillu24 marked this conversation as resolved.
Show resolved Hide resolved

const submissionFound = await checkSubmissionForRound("oracle1", 1675687989744, 735);
dillu24 marked this conversation as resolved.
Show resolved Hide resolved

expect(submissionFound).toBe(true);
});

/**
* Test for check submission without submission
*/
test('calls checkSubmissionForRound to check if there was a submission for round without submission', async () => {

const submissionFound = await checkSubmissionForRound("oracle1", 1675687989744, 736);

expect(submissionFound).toBe(false);
});

/**
* Test for query price
*/
test('calls queryPrice to query the latest price', async () => {

readVStorage.mockReturnValue(JSON.stringify({"value": "{\"blockHeight\":\"161547\",\"values\":[\"{\\\"body\\\":\\\"{\\\\\\\"amountIn\\\\\\\":{\\\\\\\"brand\\\\\\\":{\\\\\\\"@qclass\\\\\\\":\\\\\\\"slot\\\\\\\",\\\\\\\"iface\\\\\\\":\\\\\\\"Alleged: ATOM brand\\\\\\\",\\\\\\\"index\\\\\\\":0},\\\\\\\"value\\\\\\\":{\\\\\\\"@qclass\\\\\\\":\\\\\\\"bigint\\\\\\\",\\\\\\\"digits\\\\\\\":\\\\\\\"1000000\\\\\\\"}},\\\\\\\"amountOut\\\\\\\":{\\\\\\\"brand\\\\\\\":{\\\\\\\"@qclass\\\\\\\":\\\\\\\"slot\\\\\\\",\\\\\\\"iface\\\\\\\":\\\\\\\"Alleged: USD brand\\\\\\\",\\\\\\\"index\\\\\\\":1},\\\\\\\"value\\\\\\\":{\\\\\\\"@qclass\\\\\\\":\\\\\\\"bigint\\\\\\\",\\\\\\\"digits\\\\\\\":\\\\\\\"14059528\\\\\\\"}},\\\\\\\"timer\\\\\\\":{\\\\\\\"@qclass\\\\\\\":\\\\\\\"slot\\\\\\\",\\\\\\\"iface\\\\\\\":\\\\\\\"Alleged: timerService\\\\\\\",\\\\\\\"index\\\\\\\":2},\\\\\\\"timestamp\\\\\\\":{\\\\\\\"@qclass\\\\\\\":\\\\\\\"bigint\\\\\\\",\\\\\\\"digits\\\\\\\":\\\\\\\"1676499385\\\\\\\"}}\\\",\\\"slots\\\":[\\\"board05311\\\",\\\"board02810\\\",null]}\"]}"}))
dillu24 marked this conversation as resolved.
Show resolved Hide resolved

const latestPrice = await queryPrice("ATOM-USD");

expect(latestPrice).toBe(14.059528);
});

/**
* Test for get oracle invitations
*/
test('calls getOraclesInvitations to get the invitation IDs', async () => {

const invitations = await getOraclesInvitations("ATOM-USD");

expect(invitations).toStrictEqual({
"ATOM-USD": 1675687989744
});
});

/**
* Test for query round
*/
test('calls queryRound to query the latest round', async () => {

readVStorage.mockReturnValue(JSON.stringify({"value": "{\"blockHeight\":\"161542\",\"values\":[\"{\\\"body\\\":\\\"{\\\\\\\"roundId\\\\\\\":{\\\\\\\"@qclass\\\\\\\":\\\\\\\"bigint\\\\\\\",\\\\\\\"digits\\\\\\\":\\\\\\\"802\\\\\\\"},\\\\\\\"startedAt\\\\\\\":{\\\\\\\"@qclass\\\\\\\":\\\\\\\"bigint\\\\\\\",\\\\\\\"digits\\\\\\\":\\\\\\\"1676499365\\\\\\\"},\\\\\\\"startedBy\\\\\\\":\\\\\\\"agoric1lw4e4aas9q84tq0q92j85rwjjjapf8dmnllnft\\\\\\\"}\\\",\\\"slots\\\":[]}\"]}"}))
dillu24 marked this conversation as resolved.
Show resolved Hide resolved

const latestPrice = await queryRound("ATOM-USD");

expect(latestPrice).toStrictEqual({
"round_id": 802,
"started_at": 1676499365,
"started_by": "agoric1lw4e4aas9q84tq0q92j85rwjjjapf8dmnllnft",
"submission_made": false
});
});
Loading