Regression tests don't permit checking native TxID endpoints
Example commit and pipeline:
# Check that endpoint checks work.
type: check
endpoint: http://localhost:1317/thorchain/tx/details/{{ observe_txid 2 }}
asserts:
- .txs|length > 0
---
type: check
endpoint: http://localhost:1317/thorchain/tx/details/{{ native_txid -1 }}
asserts:
- .out_txs|length > 0
(This is for swaps/swaps.yaml, in which both TxIDs are referred to elsewhere.)
https://gitlab.com/thorchain/thornode/-/jobs/5975444150
Operation:
type: check
endpoint: http://localhost:1317/thorchain/tx/details/{{ native_txid -1 }}
params: {}
status: 200
asserts:
- .out_txs|length > 0
Endpoint Response:
{"error":"rpc error: code = Unknown desc = internal"}
12:28PM ERR cmd/run.go:219 > operation failed error="unexpected status code: 404" line=98 op=15 path=suites/swaps/swaps.yaml type=check
12:28PM INF ../../x/thorchain/handler_observed_txout.go:184 > handleMsgObservedTxOut request Tx:="0000000000000000000000000000000000000000000000000000000000000002: bcrt1qzf3gsk7edzwl9syyefvfhle37cjtql35tlzesk ==> bcrt1q3wrmhnh2qe98rjse30pl7u6jxszjjwl44ls6uw (Memo: OUT:D96B553D63BCC6DB749B184F566BF0B37B595B026E9AA7B35B5C7D654237C965) 8998477 BTC.BTC (gas: [10500 BTC.BTC])"
12:28PM INF ../../x/thorchain/handler_outbound_tx.go:52 > receive MsgOutboundTx request outbound tx hash=0000000000000000000000000000000000000000000000000000000000000002
12:28PM INF ../../../go/pkg/mod/github.com/tendermint/tendermint@v0.34.14/state/execution.go:235 > committed state app_hash=F8BECD92C30B379B854791266C0543A170514CA2C440FCB9FF84FE0647F5752C height=4 module=state num_txs=1
12:28PM ERR ../../x/thorchain/querier.go:1457 > fail to parse tx id error="txid error: must be 64 characters (got 20)"
12:28PM INF cmd/main.go:128 > 28/61 regression tests completed.
>> FAIL_FAST: Aborting Now <<
Relevant code I predict:
https://gitlab.com/thorchain/thornode/-/blob/v1.126.0/test/regression/cmd/template.go#L25-32
var funcMap = template.FuncMap{
"observe_txid": func(i int) string {
return fmt.Sprintf("%064x", i) // padded 64-bit hex string
},
"native_txid": func(i int) string {
// this will get double-rendered
return fmt.Sprintf("{{ native_txid %d }}", i)
},
I am currently puzzled by that I do not see where this funcMap is used:
For example, just for the OpCheck Asserts:
https://gitlab.com/thorchain/thornode/-/blob/v1.126.0/test/regression/cmd/operations.go#L302-317
for _, a := range op.Asserts {
// render the assert expression (used for native_txid)
funcMap := template.FuncMap{
"native_txid": func(i int) string {
// allow reverse indexing
nativeTxIDsMu.Lock()
defer nativeTxIDsMu.Unlock()
if i < 0 {
i += len(nativeTxIDs[routine]) + 1
}
return nativeTxIDs[routine][i-1]
},
}
tmpl := template.Must(template.Must(templates.Clone()).Funcs(funcMap).Parse(a))
expr := bytes.NewBuffer(nil)
err = tmpl.Execute(expr, nil)
(Different 'funcMap'.)
By contrast, earlier in the same function:
https://gitlab.com/thorchain/thornode/-/blob/v1.126.0/test/regression/cmd/operations.go#L236-244
if op.Endpoint == "" {
return fmt.Errorf("check")
}
// build request
req, err := http.NewRequest("GET", op.Endpoint, nil)
if err != nil {
log.Fatal().Err(err).Msg("failed to build request")
}
It's currently unclear to me how {{ observe_txid 2 }}
is correctly parsed for this endpoint.
Insights from @ursa9r 's regarding this would be greatly welcome;
in the meantime it does not appear possible to check regression test endpoints
(for ObservedTxVoters or specific streaming swaps or otherwise) for native transactions,
unless I am overlooking something.