From ff2760cd4471ef5a0fe257d330fbb4343a43a0a0 Mon Sep 17 00:00:00 2001 From: gravermistakes Date: Mon, 19 Oct 2026 17:00:56 -0700 Subject: [PATCH] test: specify M2 to M3a hub integration --- .../economy/sims/statistical/integration.test | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 core/src/economy/sims/statistical/integration.test diff --git a/core/src/economy/sims/statistical/integration.test b/core/src/economy/sims/statistical/integration.test new file mode 100644 index 0000000..13145ea --- /dev/null +++ b/core/src/economy/sims/statistical/integration.test @@ -0,0 +1,39 @@ +package require tcltest 2 +namespace import ::tcltest::* + +set here [file dirname [file normalize [info script]]] +source [file join $here .. .. stomach.tcl] + +test m3a-runner-available-1.0 {R-backed statistical runner is available in M3a CI} -body { + set s [::stomach::Economy new -history_cap 256] + set out [$s statistical_runner_available] + $s destroy + set out +} -result 1 + +test m2-to-m3a-to-hub-1.0 {price ticks calibrate M3a and publish a bounded prediction into the hub} -body { + set s [::stomach::Economy new -history_cap 256] + $s register_trader trader-a statistical + set base 100.0 + for {set i 0} {$i < 120} {incr i} { + set price [expr {$base * exp(0.0005*$i + 0.01*sin($i/7.0))}] + $s feed_publish price_tick synthetic $i [dict create token_ticker TEST price $price] 9.0 + } + set p [$s statistical_from_feed TEST daily 1200 77] + set q [$s query_predictions trader-a statistical] + set out [list [dict get $p sim_type] [expr {[dict get $p lower_bound] <= [dict get $p value]}] [expr {[dict get $p value] <= [dict get $p upper_bound]}] [dict get $q token_ticker] [dict get $q time_horizon]] + $s destroy + set out +} -result {statistical 1 1 TEST 24h} + +test m3a-insufficient-history-1.0 {M3a refuses calibration from a too-short M2 price history} -body { + set s [::stomach::Economy new -history_cap 256] + for {set i 0} {$i < 20} {incr i} { + $s feed_publish price_tick synthetic $i [dict create token_ticker TEST price [expr {100.0+$i}]] 9.0 + } + set code [catch {$s statistical_from_feed TEST daily 500 1} msg] + $s destroy + list $code $msg +} -result {1 insufficient_price_history} + +cleanupTests