Skip to content

Commit

Permalink
add historical to test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
0xngmi committed Oct 22, 2024
1 parent 68632a6 commit 02a1b87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ This is a work in progress. The goal is to eventually handle historical data. De
If you have any suggestions, want to contribute or want to chat, please join [our discord](https://discord.defillama.com/) and drop a message.

## Testing adapters
```
```bash
node test.js projects/pangolin/index.js
# Add a timestamp at the end to run the adapter at a historical timestamp
node test.js projects/aave/v3.js 1729080692
```

## Changing RPC providers
Expand Down
14 changes: 10 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const path = require("path");
require("dotenv").config();
const { ENV_KEYS } = require("./projects/helper/env");
const { util: {
blocks: { getCurrentBlocks },
blocks: { getBlocks },
humanizeNumber: { humanizeNumber },
} } = require("@defillama/sdk");
const { util } = require("@defillama/sdk");
Expand Down Expand Up @@ -142,9 +142,15 @@ function validateHallmarks(hallmark) {
// await initCache()
const chains = Object.keys(module).filter(item => typeof module[item] === 'object' && !Array.isArray(module[item]));
checkExportKeys(module, passedFile, chains)
const unixTimestamp = Math.round(Date.now() / 1000) - 60;
// const { chainBlocks } = await getCurrentBlocks([]); // fetch only ethereum block for local test
const chainBlocks = {}

let unixTimestamp = Math.round(Date.now() / 1000) - 60;
let chainBlocks = {}
const passedTimestamp = process.argv[3]
if(passedTimestamp !== undefined){
unixTimestamp = Number(passedTimestamp)
const res = await getBlocks(unixTimestamp, chains)
chainBlocks = res.chainBlocks
}
const ethBlock = chainBlocks.ethereum;
const usdTvls = {};
const tokensBalances = {};
Expand Down

0 comments on commit 02a1b87

Please sign in to comment.