-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.js
More file actions
33 lines (26 loc) · 1.05 KB
/
Copy pathTest.js
File metadata and controls
33 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const { expect } = require('chai');
const ChainlinkPriceOracle = artifacts.require('ChainlinkPriceOracle');
contract('ChainlinkPriceOracle', () => {
let oracle;
beforeEach(async () => {
// Deploy a new instance of the contract before each test.
oracle = await ChainlinkPriceOracle.new();
});
it('should update the price of an asset', async () => {
// Update the price of an asset.
await oracle.updatePrice('ETH', 100);
// Get the current price of the asset.
const price = await oracle.getPrice('ETH');
// Verify that the price was updated correctly.
expect(price).to.equal(100);
});
it('should emit a PriceUpdated event when the price is updated', async () => {
// Update the price of an asset.
const tx = await oracle.updatePrice('ETH', 100);
// Verify that the transaction emitted a PriceUpdated event.
expect(tx.logs.length).to.equal(1);
expect(tx.logs[0].event).to.equal('PriceUpdated');
expect(tx.logs[0].args.asset).to.equal('ETH');
expect(tx.logs[0].args.price).to.equal(100);
});
});