From c65b1c46dbeede620d252bef76d34bf8c73b75be Mon Sep 17 00:00:00 2001 From: Maximiliano Duthey Date: Wed, 4 Mar 2026 11:54:02 -0300 Subject: [PATCH] feat: add method to access TII protocol specification and corresponding test --- sdk/src/tii/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sdk/src/tii/mod.rs b/sdk/src/tii/mod.rs index 94f4b88..f829801 100644 --- a/sdk/src/tii/mod.rs +++ b/sdk/src/tii/mod.rs @@ -229,6 +229,10 @@ impl Protocol { Self::from_string(code) } + pub fn spec(&self) -> &spec::TiiFile { + &self.spec + } + fn ensure_tx(&self, key: &str) -> Result<&Transaction, Error> { let tx = self.spec.transactions.get(key); let tx = tx.ok_or(Error::UnknownTx(key.to_string()))?; @@ -607,4 +611,16 @@ mod tests { dbg!(&tx); } + + #[test] + fn spec_is_accessible() { + let manifest_dir = env!("CARGO_MANIFEST_DIR"); + let tii = format!("{manifest_dir}/../examples/transfer.tii"); + + let protocol = Protocol::from_file(&tii).unwrap(); + let spec = protocol.spec(); + + assert_eq!(spec.protocol.name, "unknown"); + assert!(spec.transactions.contains_key("transfer")); + } }