Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rusk-wallet: Replace test-wallet in rusk tests #2281

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rusk-wallet/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ impl Ord for NoteData {
}
}

impl AsRef<Note> for NoteData {
fn as_ref(&self) -> &Note {
&self.note
}
}

impl Serializable<{ u64::SIZE + Note::SIZE }> for NoteData {
type Error = dusk_bytes::Error;
/// Converts a Note into a byte representation
Expand Down
38 changes: 30 additions & 8 deletions rusk-wallet/src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ mod sync;

use dusk_bytes::Serializable;
use execution_core::{
transfer::{phoenix::Prove, Transaction},
signatures::bls::PublicKey as AccountPublicKey,
transfer::{moonlight::AccountData, phoenix::Prove, Transaction},
Error as ExecutionCoreError,
};
use flume::Receiver;
Expand Down Expand Up @@ -139,15 +140,15 @@ impl State {
/// Skips writing the proof for non phoenix transactions
pub fn prove_and_propagate(
&self,
utx: Transaction,
tx: Transaction,
) -> Result<Transaction, Error> {
let status = self.status;
let prover = &self.prover;
let mut utx = utx;
let mut tx = tx;

if let Transaction::Phoenix(tx) = &mut utx {
if let Transaction::Phoenix(utx) = &mut tx {
let status = self.status;
let proof = tx.proof();
let proof = utx.proof();

status("Attempt to prove tx...");

Expand All @@ -158,12 +159,12 @@ impl State {
ExecutionCoreError::PhoenixCircuit(e.to_string())
})?;

tx.set_proof(proof);
utx.set_proof(proof);

status("Proving sucesss!");
}

let tx_bytes = utx.to_var_bytes();
let tx_bytes = tx.to_var_bytes();

status("Attempt to preverify tx...");
let preverify_req = RuskRequest::new("preverify", tx_bytes.clone());
Expand All @@ -175,7 +176,7 @@ impl State {
let _ = self.client.call(2, "Chain", &propagate_req).wait()?;
status("Transaction propagated!");

Ok(utx)
Ok(tx)
}

/// Find notes for a view key, starting from the given block height.
Expand Down Expand Up @@ -215,6 +216,27 @@ impl State {
inputs
}

pub(crate) fn fetch_account(
&self,
pk: &AccountPublicKey,
) -> Result<AccountData, Error> {
let status = self.status;
status("Fetching account-data...");

let account = self
.client
.contract_query::<_, 1024>(TRANSFER_CONTRACT, "account", pk)
.wait()?;
let account = rkyv::from_bytes(&account).map_err(|_| Error::Rkyv)?;
status("account-data received!");

let account_address = pk.to_bytes().to_vec();
let account_address = bs58::encode(account_address).into_string();
println!("Account address: {}", account_address);

Ok(account)
}

pub(crate) fn fetch_notes(
&self,
pk: &PhoenixPublicKey,
Expand Down
Loading
Loading