Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fix(tests): Fix failing github tests
  • Loading branch information
Owliie committed Dec 11, 2025
commit 774e7d6380fde831f841e13d431b26c86c974495
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const PriceFeedConfigCard = ({ feed }: DataFeedCardProps) => {
title: 'Price Feed Configuration',
description: '',
items: [
{ label: 'Base', value: feed.additional_feed_info.pair.base },
{ label: 'Quote', value: feed.additional_feed_info.pair.quote },
{ label: 'Base', value: feed.additional_feed_info.pair?.base },
{ label: 'Quote', value: feed.additional_feed_info.pair?.quote },
{ label: 'Decimals', value: feed.additional_feed_info.decimals },
{ label: 'Category', value: feed.additional_feed_info.category },
],
Expand Down
1 change: 1 addition & 0 deletions apps/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@blocksense/base-utils": "workspace:*",
"@blocksense/config-types": "workspace:*",
"@blocksense/contracts": "workspace:*",
"@blocksense/dev": "workspace:*",
"@chainsafe/bls": "^8.2.0",
"@effect/cluster": "^0.48.2",
"@effect/experimental": "^0.54.6",
Expand Down
17 changes: 11 additions & 6 deletions apps/e2e-tests/src/test-scenarios/wit/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ describe.sequential('E2E Tests with process-compose', () => {

let existingFiles: string[] = [];

const dirPath = join(rootDir, '/apps/e2e-tests/src/test-scenarios/wit/');

const deleteTestFiles = () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const allFiles = yield* fs.readDirectory(__dirname);
const allFiles = yield* fs.readDirectory(dirPath);
const newFiles = allFiles.filter(file => !existingFiles.includes(file));
if (newFiles.length > 0) {
for (const file of newFiles) {
yield* fs.remove(join(__dirname, file), {
yield* fs.remove(join(dirPath, file), {
force: true,
recursive: true,
});
Expand All @@ -86,7 +88,7 @@ describe.sequential('E2E Tests with process-compose', () => {
// track files created during the tests
existingFiles = await Effect.runPromise(
FileSystem.FileSystem.pipe(
Effect.flatMap(fs => fs.readDirectory(__dirname)),
Effect.flatMap(fs => fs.readDirectory(dirPath)),
Effect.provide(NodeContext.layer),
),
);
Expand Down Expand Up @@ -258,8 +260,11 @@ describe.sequential('E2E Tests with process-compose', () => {
for (const feedId of feedIds) {
const value = latestFeedsInfoLocal[feedId.toString()].value;
const stride = feedId >> 120n;
const joinedValue = Array.isArray(value)
? `0x${value.map(val => val.slice(2)).join('')}`
: value;

expect(BigInt((value.length - 2) / 2 / 32)).toEqual(2n ** stride);
expect(BigInt((joinedValue.length - 2) / 2 / 32)).toEqual(2n ** stride);

yield* Command.make(
'just',
Expand All @@ -285,7 +290,7 @@ describe.sequential('E2E Tests with process-compose', () => {
const contracts = yield* FileSystem.FileSystem.pipe(
Effect.flatMap(fs =>
fs
.readDirectory(__dirname + '/generated-decoders')
.readDirectory(dirPath + 'generated-decoders')
.pipe(Effect.map(files => files.map(file => file))),
),
);
Expand Down Expand Up @@ -351,7 +356,7 @@ describe.sequential('E2E Tests with process-compose', () => {
address: contractAddress as EthereumAddress,
abi,
functionName: 'decode',
args: [value],
args: [joinedValue],
}),
)) as {
eventName: string;
Expand Down
5 changes: 2 additions & 3 deletions apps/e2e-tests/src/utils/services/onchain.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('getDataFeedsInfoFromNetwork', () => {

const data =
'0x0000000000000000000000000000000000000a3549cbad30000001986c265bf0';
const value = 11223987629360;

beforeEach(() => {
vi.spyOn(AggregatedDataFeedStoreConsumer, 'create').mockReturnValue(
Expand Down Expand Up @@ -49,7 +48,7 @@ describe('getDataFeedsInfoFromNetwork', () => {
);

const expected: FeedsValueAndRound = {
'1': { value, round: 42 },
'1': { value: data, round: 42 },
};

expect(result).toEqual(expected);
Expand All @@ -74,7 +73,7 @@ describe('getDataFeedsInfoFromNetwork', () => {
);

const expected: FeedsValueAndRound = {
'2': { value, round: 99 },
'2': { value: data, round: 99 },
};

expect(result).toEqual(expected);
Expand Down
2 changes: 1 addition & 1 deletion apps/e2e-tests/src/utils/services/onchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AggregatedDataFeedStoreConsumer } from '@blocksense/contracts/viem';

export type FeedsValueAndRound = Record<
string,
{ value: HexDataString; round: number }
{ value: HexDataString | HexDataString[]; round: number }
>;

/**
Expand Down
15 changes: 8 additions & 7 deletions apps/trigger-oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ impl OracleTrigger {
}
}

fn parse_encoded_feed_id(feed_id: &str, default_strides: &HashMap<FeedId, Stride>) -> Option<EncodedFeedId> {
fn parse_encoded_feed_id(
feed_id: &str,
default_strides: &HashMap<FeedId, Stride>,
) -> Option<EncodedFeedId> {
let mut parts = feed_id.split(':');
let first = parts.next()?;
let second = parts.next();
Expand All @@ -433,12 +436,10 @@ impl OracleTrigger {
}
}
None => {
let feed_id = first
.parse::<u128>()
.ok()?;
let feed_id = first.parse::<u128>().ok()?;
let stride = default_strides.get(&feed_id).copied().unwrap_or(0);
EncodedFeedId::try_new(feed_id, stride)
},
}
}
}

Expand Down Expand Up @@ -1131,8 +1132,8 @@ fn update_latest_votes(
) {
for vote in batch {
let Some(encoded_feed_id) =
OracleTrigger::parse_encoded_feed_id(&vote.payload_metadata.feed_id, &HashMap::new()) // TODO: pass the actual strides from config for second round consensus

OracleTrigger::parse_encoded_feed_id(&vote.payload_metadata.feed_id, &HashMap::new())
// TODO: pass the actual strides from config for second round consensus
else {
tracing::warn!(
"Failed to parse feed id '{}' when updating latest votes",
Expand Down
10 changes: 5 additions & 5 deletions libs/feed_registry/src/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ impl FeedAggregate {
}

// Find the string with the maximum occurrences
if frequency_map_text.len() > 0 {
if !frequency_map_text.is_empty() {
assert!(
frequency_map_bytes.len() == 0,
frequency_map_bytes.is_empty(),
"Mixing Text and Bytes in MajorityVoteAggregator is not allowed!"
);
let result = frequency_map_text
Expand All @@ -66,7 +66,7 @@ impl FeedAggregate {
.unwrap()
.clone();
FeedType::Text(result)
} else if frequency_map_bytes.len() > 0 {
} else if !frequency_map_bytes.is_empty() {
let most_frequent = frequency_map_bytes
.into_iter()
.max_by_key(|&(_, count)| count)
Expand All @@ -76,7 +76,7 @@ impl FeedAggregate {

fn prefix_size(stride: u8) -> u8 {
// `2 ^ (n + 1)` divided by 8, rounded up
(stride + 5 + 7) / 8
(stride + 5).div_ceil(8)
}

fn right_align_truncate(dst: &mut [u8], src: &[u8]) {
Expand Down Expand Up @@ -108,7 +108,7 @@ impl FeedAggregate {
let mut result = [prefix, most_frequent].concat();

// Calculate max SSZ slots and pad with zeros
let max_ssz_slots = ((result.len() - 2) + 63) / 64;
let max_ssz_slots = (result.len() - 2).div_ceil(64);
let target_length = max_ssz_slots * 64 + 2;

result.resize(target_length, 0);
Expand Down
7 changes: 5 additions & 2 deletions libs/ts/config-types/src/data-feeds-config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ export const decodeFeedsConfig = S.decodeUnknownSync(FeedsConfigSchema);
/**
* Schema for the data feed type.
*/
export const FeedTypeSchema = S.Union(S.Literal('price-feed'), S.Literal('sport-feed')).annotations({
export const FeedTypeSchema = S.Union(
S.Literal('price-feed'),
S.Literal('sport-feed'),
).annotations({
identifier: 'FeedType',
});

Expand Down Expand Up @@ -195,7 +198,7 @@ export const NewFeedSchema = S.mutable(
aggregation: S.Union(
S.Literal('median'),
S.Literal('average'),
S.Literal('majority')
S.Literal('majority'),
).annotations({
identifier: 'QuorumAggregation',
}),
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ __metadata:
languageName: unknown
linkType: soft

"@blocksense/dev@workspace:apps/dev":
"@blocksense/dev@workspace:*, @blocksense/dev@workspace:apps/dev":
version: 0.0.0-use.local
resolution: "@blocksense/dev@workspace:apps/dev"
dependencies:
Expand Down Expand Up @@ -1686,6 +1686,7 @@ __metadata:
"@blocksense/base-utils": "workspace:*"
"@blocksense/config-types": "workspace:*"
"@blocksense/contracts": "workspace:*"
"@blocksense/dev": "workspace:*"
"@chainsafe/bls": "npm:^8.2.0"
"@effect/cluster": "npm:^0.48.2"
"@effect/experimental": "npm:^0.54.6"
Expand Down