Use alloc for no_std builds
[rust-lightning] / lightning / src / util / test_utils.rs
index 153f2f28eed11ffe7e55536c98c191714edb6443..43bb1ef930391d7966af82308d74aef1ad3e6073 100644 (file)
@@ -32,13 +32,15 @@ use bitcoin::network::constants::Network;
 use bitcoin::hash_types::{BlockHash, Txid};
 
 use bitcoin::secp256k1::{SecretKey, PublicKey, Secp256k1, Signature};
+use bitcoin::secp256k1::recovery::RecoverableSignature;
 
 use regex;
 
-use std::time::Duration;
+use prelude::*;
+use core::time::Duration;
 use std::sync::{Mutex, Arc};
-use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
-use std::{cmp, mem};
+use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
+use core::{cmp, mem};
 use std::collections::{HashMap, HashSet, VecDeque};
 use chain::keysinterface::InMemorySigner;
 
@@ -75,6 +77,7 @@ impl keysinterface::KeysInterface for OnlyReadsKeysInterface {
        fn read_chan_signer(&self, reader: &[u8]) -> Result<Self::Signer, msgs::DecodeError> {
                EnforcingSigner::read(&mut std::io::Cursor::new(reader))
        }
+       fn sign_invoice(&self, _invoice_preimage: Vec<u8>) -> Result<RecoverableSignature, ()> { unreachable!(); }
 }
 
 pub struct TestChainMonitor<'a> {
@@ -483,6 +486,10 @@ impl keysinterface::KeysInterface for TestKeysInterface {
                        disable_revocation_policy_check: self.disable_revocation_policy_check,
                })
        }
+
+       fn sign_invoice(&self, invoice_preimage: Vec<u8>) -> Result<RecoverableSignature, ()> {
+               self.backing.sign_invoice(invoice_preimage)
+       }
 }
 
 
@@ -618,8 +625,8 @@ impl OnRegisterOutput {
        }
 }
 
-impl std::fmt::Debug for OnRegisterOutput {
-       fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for OnRegisterOutput {
+       fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
                f.debug_struct("OnRegisterOutput")
                        .field("outpoint", &self.outpoint())
                        .field("script_pubkey", self.script_pubkey())