Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgcrosta committed Dec 20, 2023
1 parent 9794220 commit 4f538c3
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ impl DosUnboundedOperation {

#[cfg(test)]
mod tests {
use crate::DosUnboundedOperation;
use soroban_sdk::Env;

use crate::{DosUnboundedOperation, DosUnboundedOperationClient};

#[test]
fn test_for_loop() {
// Given
// ..
let env = Env::default();
let contract_id = env.register_contract(None, DosUnboundedOperation);
let client = DosUnboundedOperationClient::new(&env, &contract_id);

// When
let count = DosUnboundedOperation::restricted_loop_with_const();
let count = client.restricted_loop_with_const();

// Then
assert_eq!(count, 499500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ impl DosUnboundedOperation {

#[cfg(test)]
mod tests {
use crate::DosUnboundedOperation;
use soroban_sdk::Env;

use crate::{DosUnboundedOperation, DosUnboundedOperationClient};

#[test]
fn test_for_loop() {
// Given
// ..
let env = Env::default();
let contract_id = env.register_contract(None, DosUnboundedOperation);
let client = DosUnboundedOperationClient::new(&env, &contract_id);

// When
let for_loop_count = 1000;
let count = DosUnboundedOperation::unrestricted_loop(for_loop_count);
let count = client.unrestricted_loop(&for_loop_count);

// Then
assert_eq!(count, 499500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ impl DosUnboundedOperation {
#[cfg(test)]
mod tests {

use crate::DosUnboundedOperation;
use soroban_sdk::Env;

use crate::{DosUnboundedOperation, DosUnboundedOperationClient};

#[test]
fn test_for_loop() {
// Given
// ...
let env = Env::default();
let contract_id = env.register_contract(None, DosUnboundedOperation);
let client = DosUnboundedOperationClient::new(&env, &contract_id);

// When
let count = DosUnboundedOperation::safe_loop_with_struct();
let count = client.safe_loop_with_struct();

// Then
assert_eq!(count, 499500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ impl DosUnboundedOperation {
#[cfg(test)]
mod tests {

use crate::{DosUnboundedOperation, KnownData};
use soroban_sdk::Env;

use crate::{DosUnboundedOperation, DosUnboundedOperationClient, KnownData};

#[test]
fn test_for_loop() {
// Given
// ...
let env = Env::default();
let contract_id = env.register_contract(None, DosUnboundedOperation);
let client = DosUnboundedOperationClient::new(&env, &contract_id);

// When
let unknown_data = KnownData { fixed_value: 1000 };
let count = DosUnboundedOperation::unsafe_loop_with_struct(unknown_data);
let count = client.unsafe_loop_with_struct(&unknown_data);

// Then
assert_eq!(count, 499500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ impl DosUnboundedOperation {
#[cfg(test)]
mod tests {

use crate::DosUnboundedOperation;
use soroban_sdk::Env;

use crate::{DosUnboundedOperation, DosUnboundedOperationClient};

#[test]
fn test_for_loop() {
// Given
// ...
let env = Env::default();
let contract_id = env.register_contract(None, DosUnboundedOperation);
let client = DosUnboundedOperationClient::new(&env, &contract_id);

// When
let count = DosUnboundedOperation::safe_loop_with_array();
let count = client.safe_loop_with_array();

// Then
assert_eq!(count, 28);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ mod tests {

use soroban_sdk::{BytesN, Env};

use crate::DosUnboundedOperation;
use crate::{DosUnboundedOperation, DosUnboundedOperationClient};

#[test]
fn test_for_loop() {
// Given
let env = Env::default();
let contract_id = env.register_contract(None, DosUnboundedOperation);
let client = DosUnboundedOperationClient::new(&env, &contract_id);

// When
let unknown_array = BytesN::from_array(&env, &[0; 8]);
let count = DosUnboundedOperation::unsafe_loop_with_array(unknown_array);
let count = client.unsafe_loop_with_array(&unknown_array);

// Then
assert_eq!(count, 28);
Expand Down

0 comments on commit 4f538c3

Please sign in to comment.