Skip to content

Commit

Permalink
Merge pull request #20 from dusk-network/refactorings
Browse files Browse the repository at this point in the history
More comments and renaming
  • Loading branch information
miloszm authored Sep 29, 2023
2 parents c1e12c7 + bc315b8 commit d452ab0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
33 changes: 27 additions & 6 deletions integration-tests/tests/int_test_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,25 @@ fn find_owned_license(
Ok((pos, deserialise_license(&lic_ser)))
}

///
/// test user_round_trip realizes the following scenario:
/// - creates request (User)
/// - based on the request, calls issue_license (LP)
/// - calls get_licenses, obtains license and position (User)
/// - calls get_merkle_opening for a given position, obtains the opening (User)
/// - based on license and opening, computes proof (User)
/// - calls use_license and creates a session_id (User)
/// - use_license verifies the proof, creates the corresponding session (License
/// Contract)
/// - calls get_session based on a session id given to the SP by the User (SP)
///
/// - Note that session_id is created by the User and not returned by
/// use_license. Although use_license, internally, also creates the same
/// session_id, it is not returned by it because contract state changing
/// methods do not have the ability to return values. It is assumed that
/// license_id created by the user and by contract are the same.
/// - Note that after each contract method call the test waits for transaction
/// to confirm.
#[tokio::test(flavor = "multi_thread")]
#[cfg_attr(not(feature = "exp_tests"), ignore)]
async fn user_round_trip() -> Result<(), Error> {
Expand Down Expand Up @@ -244,6 +263,14 @@ async fn user_round_trip() -> Result<(), Error> {
let blockchain_config =
BlockchainAccessConfig::load_path(blockchain_config_path)?;

let wallet_path = WalletPath::from(
PathBuf::from(WALLET_PATH).as_path().join("wallet.dat"),
);

let client = RuskHttpClient::new(blockchain_config.rusk_address.clone());

// create request

let request_json: RequestJson = RequestJson::from_file(request_path)?;

let request = RequestCreator::create_from_hex_args(
Expand All @@ -255,12 +282,6 @@ async fn user_round_trip() -> Result<(), Error> {
let ssk_user_bytes = hex::decode(request_json.user_ssk)?;
let ssk_user = SecretSpendKey::from_slice(ssk_user_bytes.as_slice())?;

let wallet_path = WalletPath::from(
PathBuf::from(WALLET_PATH).as_path().join("wallet.dat"),
);

let client = RuskHttpClient::new(blockchain_config.rusk_address.clone());

// as a LP, call issue license, wait for tx to confirm

show_state(&client, "before issue_license").await?;
Expand Down
2 changes: 1 addition & 1 deletion moat-core/src/blockchain_requests/payload_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl PayloadSender {
let wallet_accessor =
WalletAccessor::new(wallet_path.clone(), password.clone());
let tx_id = wallet_accessor
.send(
.execute_contract_method(
payload,
contract_id,
method.as_ref().to_string(),
Expand Down
4 changes: 3 additions & 1 deletion wallet-accessor/src/wallet_accessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ impl WalletAccessor {
}
}

pub async fn send<C>(
/// submits a transaction which will execute a given method
/// of a given contract
pub async fn execute_contract_method<C>(
&self,
data: C,
contract_id: ModuleId,
Expand Down

0 comments on commit d452ab0

Please sign in to comment.