tester: add ota control message sends to ctrl bin

This commit is contained in:
decentclock
2022-09-25 19:30:18 -04:00
parent f59aa3de57
commit 2a4945f44a
2 changed files with 13 additions and 2 deletions

View File

@@ -2,7 +2,9 @@ use anyhow::Result;
use sphinx_auther::nonce;
use sphinx_auther::secp256k1::{PublicKey, SecretKey};
use sphinx_auther::token::Token;
pub use sphinx_glyph::types::{Config, ControlMessage, ControlResponse, Interval, Policy};
pub use sphinx_glyph::types::{
Config, ControlMessage, ControlResponse, Interval, OtaParams, Policy,
};
use std::sync::{Arc, Mutex};
// u64 is the nonce. Each signature must have a higher nonce

View File

@@ -1,6 +1,6 @@
use dotenv::dotenv;
use serde::{Deserialize, Serialize};
use sphinx_key_parser::control::{ControlMessage, Controller};
use sphinx_key_parser::control::{ControlMessage, Controller, OtaParams};
use sphinx_key_signer::lightning_signer::bitcoin::Network;
use std::env;
use std::time::Duration;
@@ -25,6 +25,15 @@ async fn main() -> anyhow::Result<()> {
let seed = hex::decode(seed_string).expect("yo");
let mut ctrl = controller_from_seed(&Network::Regtest, &seed, nonce);
let version_string: String = env::var("VERSION").unwrap_or("0".to_string());
let version: u64 = version_string.parse::<u64>().expect("failed to parse version");
let ota_url: String = env::var("OTA_URL").unwrap_or("http://192.168.1.10/sphinx-update-".to_string());
let control_message = ControlMessage::Ota(OtaParams {
version: version,
url: ota_url
});
//let msg = ctrl.build_msg(control_message)?;
let msg = ctrl.build_msg(ControlMessage::Nonce)?;
let msg_hex = hex::encode(&msg);