Skip to content

Commit

Permalink
chore: updates, test hangs
Browse files Browse the repository at this point in the history
  • Loading branch information
drewstone committed Dec 14, 2024
1 parent 0577883 commit 4f9ad3c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 37 deletions.
4 changes: 3 additions & 1 deletion contracts/src/SilentTimelockEncryptionBlueprint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ contract SilentTimelockEncryptionBlueprint is BlueprintServiceManagerBase {
function getAllSTEPublicKeys(uint64 serviceId) external view returns (bytes[] memory) {
address[] memory operators = serviceOperators[serviceId];
bytes[] memory publicKeys = new bytes[](operators.length);
bytes memory empty = bytes("");
for (uint256 i = 0; i < operators.length; i++) {
publicKeys[i] = operatorSTEPublicKeys[serviceId][operators[i]];
bytes memory key = operatorSTEPublicKeys[serviceId][operators[i]];
publicKeys[i] = key.length == 0 ? empty : key;
}
return publicKeys;
}
Expand Down
6 changes: 4 additions & 2 deletions contracts/test/SilentTimelockEncryptionBlueprint.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ contract SilentTimelockEncryptionBlueprintTest is Test {

function setUp() public {
rootChain = address(0x1);
operator1PublicKey = hex"0414463bfb5433001c187e7a28c480d3945db9279ba4ef96f29c5e0e565f56b254d5c8d1d4c3a8d1b7c0b7d2f3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2e2";
operator2PublicKey = hex"047f316ac29a1c2a5e6e5c8cff51b225af088b5066e569c73ba6eba896a07c560f54a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0f0";
operator1PublicKey =
hex"0414463bfb5433001c187e7a28c480d3945db9279ba4ef96f29c5e0e565f56b254d5c8d1d4c3a8d1b7c0b7d2f3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2e2";
operator2PublicKey =
hex"047f316ac29a1c2a5e6e5c8cff51b225af088b5066e569c73ba6eba896a07c560f54a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0f0";
operator1 = operatorAddress(operator1PublicKey);
operator2 = operatorAddress(operator2PublicKey);

Expand Down
4 changes: 2 additions & 2 deletions src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::SilentTimelockEncryptionBlueprint;
/// Decrypts a ciphertext using the threshold decryption protocol
#[sdk::job(
id = 0,
params(ciphertext, threshold),
params(threshold, ciphertext),
result(_),
event_listener(
listener = TangleEventListener::<ServiceContext, JobCalled>,
Expand All @@ -33,8 +33,8 @@ use crate::SilentTimelockEncryptionBlueprint;
),
)]
pub async fn decrypt_ciphertext(
ciphertext: Vec<u8>,
threshold: u16,
ciphertext: Vec<u8>,
context: ServiceContext,
) -> Result<Vec<u8>, DecryptError> {
let blueprint_id = context
Expand Down
38 changes: 6 additions & 32 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ mod e2e {

const N: usize = 3;
const T: usize = N / 2 + 1;
let node_config = NodeConfig::new(true);
let node_config = NodeConfig::new(true).with_log_level("debug");
new_test_ext_blueprint_manager::<N, 1, _, _, _>(
"",
run_test_blueprint_manager,
Expand Down Expand Up @@ -120,36 +120,6 @@ mod e2e {
.expect("Failed to get receipt");
}

let provider = alloy_provider::ProviderBuilder::new()
.with_recommended_fillers()
.on_ws(alloy_provider::WsConnect::new(opts.ws_rpc_url.clone()))
.await
.unwrap();
let contract =
SilentTimelockEncryptionBlueprint::new(blueprint_manager_address, provider);
// Verify all public keys were registered correctly
let registered_keys = contract
.getAllSTEPublicKeys(service_id)
.call()
.await
.map(|v| v._0)
.expect("Failed to get registered public keys");

assert_eq!(
registered_keys.len(),
N,
"Not all public keys were registered"
);

for (i, registered_key) in registered_keys.iter().enumerate() {
assert_eq!(
registered_key.as_ref(),
keypairs[i].public_key.as_slice(),
"Public key mismatch for operator {}",
i
);
}

let call_id = get_next_call_id(client)
.await
.expect("Failed to get next job id")
Expand All @@ -160,7 +130,11 @@ mod e2e {
// Create a mock ciphertext for testing
let ciphertext = vec![0u8; 32]; // Mock ciphertext
let threshold = Field::Uint16(T as u16);
let ciphertext_field = Field::Bytes(BoundedVec(ciphertext));
let mut ciphertext_bytes = Vec::new();
for i in 0..32 {
ciphertext_bytes.push(Field::Uint8(ciphertext[i]));
}
let ciphertext_field = Field::List(BoundedVec(ciphertext_bytes));
let job_args = Args::from([ciphertext_field, threshold]);

let call_id = get_next_call_id(client)
Expand Down

0 comments on commit 4f9ad3c

Please sign in to comment.