First commit

This commit is contained in:
2025-05-13 19:41:33 +02:00
commit 1ec1154796
21 changed files with 7373 additions and 0 deletions

1
test/.git-folder-keeper Normal file
View File

@@ -0,0 +1 @@
This is a placeholder file to ensure the parent directory in the git repository. Feel free to remove.

View File

@@ -0,0 +1,41 @@
// test/SargaTrxUsdPrice.test.js
require('dotenv').config()
const TronWeb = require('tronweb')
const HttpProvider = TronWeb.providers.HttpProvider
const API_URL = process.env.TRON_API
const fullNode = new HttpProvider(API_URL)
const solidityNode = new HttpProvider(API_URL)
const eventServer = API_URL
const tronWeb = new TronWeb(fullNode, solidityNode, eventServer)
let assert
const SargaTrxUsdPrice = artifacts.require('SargaTrxUsdPrice')
contract('SargaTrxUsdPrice', () => {
it('get TRX/USD value', async () => {
// carga Chai como ESM y extrae assert
const chaiModule = await import('chai')
assert = chaiModule.assert
// 1) Load already deployed contract
const distributor = await SargaTrxUsdPrice.at(process.env.CONTRACT_ADDRESS)
// 2) Call the getTrxUsdPrice function
const trxUsdPrice = await distributor.getLatestPrice().call()
console.log(
'TRX/USD price:',
parseFloat(trxUsdPrice.toString()) / 10 ** 8,
'USD'
)
// 3) Assert the value is greater than 0
assert.isAbove(
parseFloat(trxUsdPrice),
0,
'TRX/USD price should be greater than 0'
)
})
})