mirror of
https://github.com/luxfi/oracle.git
synced 2026-10-30 15:23:21 +00:00
Mirrors the luxfi/relay layout:
vm/ — chain VM (O-Chain). luxd plugin host for the consensus +
state layer of oracle feeds, observations, aggregations.
Source of truth.
cmd/oracled — standalone operator daemon. Fetches external data sources
(Bitcoin, OP_NET, Chainlink, Pyth, etc.), signs Observation
messages, submits to O-Chain. No luxd validator required.
The chain VM is the security boundary; oracled is just an operator-side
emitter. Aggregation + canonical value selection still happen on-chain.
Build (GOWORK=off): exit 0
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package vm
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/luxfi/consensus/core/choices"
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
func TestOracleVertexConflicts_SameFeedRound(t *testing.T) {
|
|
feedID := ids.GenerateTestID()
|
|
|
|
v1 := &OracleVertex{
|
|
id: ids.GenerateTestID(),
|
|
status: choices.Processing,
|
|
keys: []FeedRoundKey{{FeedID: feedID, Round: 42}},
|
|
}
|
|
v2 := &OracleVertex{
|
|
id: ids.GenerateTestID(),
|
|
status: choices.Processing,
|
|
keys: []FeedRoundKey{{FeedID: feedID, Round: 42}},
|
|
}
|
|
|
|
if !v1.Conflicts(v2) {
|
|
t.Fatal("expected conflict: same feedID + round")
|
|
}
|
|
if !v2.Conflicts(v1) {
|
|
t.Fatal("expected conflict: symmetric check failed")
|
|
}
|
|
}
|
|
|
|
func TestOracleVertexConflicts_DifferentFeeds(t *testing.T) {
|
|
v1 := &OracleVertex{
|
|
id: ids.GenerateTestID(),
|
|
status: choices.Processing,
|
|
keys: []FeedRoundKey{{FeedID: ids.GenerateTestID(), Round: 42}},
|
|
}
|
|
v2 := &OracleVertex{
|
|
id: ids.GenerateTestID(),
|
|
status: choices.Processing,
|
|
keys: []FeedRoundKey{{FeedID: ids.GenerateTestID(), Round: 42}},
|
|
}
|
|
|
|
if v1.Conflicts(v2) {
|
|
t.Fatal("expected no conflict: different feeds commute even at same round")
|
|
}
|
|
}
|
|
|
|
func TestOracleVertexConflicts_SameFeedDifferentRound(t *testing.T) {
|
|
feedID := ids.GenerateTestID()
|
|
|
|
v1 := &OracleVertex{
|
|
id: ids.GenerateTestID(),
|
|
status: choices.Processing,
|
|
keys: []FeedRoundKey{{FeedID: feedID, Round: 1}},
|
|
}
|
|
v2 := &OracleVertex{
|
|
id: ids.GenerateTestID(),
|
|
status: choices.Processing,
|
|
keys: []FeedRoundKey{{FeedID: feedID, Round: 2}},
|
|
}
|
|
|
|
if v1.Conflicts(v2) {
|
|
t.Fatal("expected no conflict: same feed but different rounds")
|
|
}
|
|
}
|