Skip to content

Commit

Permalink
fix script and test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Oct 12, 2023
1 parent 136e475 commit a8c8e00
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
5 changes: 3 additions & 2 deletions shinkai-libs/shinkai-message-pyo3/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ output=$(maturin build -i python)

# If maturin develop is successful, extract the path of the built wheel file
if [ $? -eq 0 ]; then
wheel_file=$(echo "$output" | grep -o '/.*\.whl')

# Find the wheel file that starts with "shinkai_message_pyo3" in the "./target/wheels/" directory
wheel_file=$(find ./target/wheels/ -name 'shinkai_message_pyo3*.whl' -print -quit)

# Update the installed package using the built wheel file
pip install --upgrade "$wheel_file"

Expand Down
1 change: 0 additions & 1 deletion shinkai-libs/shinkai-message-pyo3/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod shinkai_pyo3_wrapper;

use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,42 @@ def test_ack_message(self):
self.assertEqual(result_json["encryption"], "None")
self.assertEqual(result_json["version"], "V1_0")

def test_initial_registration_with_no_code_for_device(self):
my_encryption_sk_string = '7008829b80ae4350cf049e48d8bce4714e216b674fff0bf34f97f7b98d928d3f'
my_encryption_pk_string = '5b0d4a7f7135ebe6712a65256b9bcb2cf79ee7425407da3cbb51f07dd9d68235'

my_identity_sk_string = 'b6baf0fa268f993c57223d5db96e5e1de776fcb0195ee6137f33de9d8d9dd749'
my_identity_pk_string = '4e91b8ca811cdb07c636190e3f1bc39edcf8ac47cfd4d1c3267fec3be570e740'
node = "@@node1.shinkai"

# _registration_with_no_code_for_device
result = shinkai_message_pyo3.PyShinkaiMessageBuilder.initial_registration_with_no_code_for_device(
my_encryption_sk_string, # device
my_identity_sk_string, # device
my_encryption_sk_string, # profile
my_identity_sk_string, # profile
"main_device",
node,
"",
node,
)

# print("Result of initial registration no code:", result)

# Parse the result as a JSON object
result_json = json.loads(result)

# Add assertions to check the fields of the result
self.assertEqual(result_json["body"]["unencrypted"]["message_data"]["unencrypted"]["message_raw_content"], '{"code":"","registration_name":"main_device","device_identity_pk":"4e91b8ca811cdb07c636190e3f1bc39edcf8ac47cfd4d1c3267fec3be570e740","device_encryption_pk":"5b0d4a7f7135ebe6712a65256b9bcb2cf79ee7425407da3cbb51f07dd9d68235","profile_identity_pk":"4e91b8ca811cdb07c636190e3f1bc39edcf8ac47cfd4d1c3267fec3be570e740","profile_encryption_pk":"5b0d4a7f7135ebe6712a65256b9bcb2cf79ee7425407da3cbb51f07dd9d68235","identity_type":"device","permission_type":"admin"}')
self.assertEqual(result_json["body"]["unencrypted"]["message_data"]["unencrypted"]["message_content_schema"], "UseRegistrationCode")
self.assertEqual(result_json["body"]["unencrypted"]["internal_metadata"]["sender_subidentity"], "")
self.assertEqual(result_json["body"]["unencrypted"]["internal_metadata"]["recipient_subidentity"], "")
self.assertEqual(result_json["body"]["unencrypted"]["internal_metadata"]["inbox"], "inbox::@@node1.shinkai::@@node1.shinkai::false")
self.assertEqual(result_json["body"]["unencrypted"]["internal_metadata"]["encryption"], "None")
self.assertEqual(result_json["external_metadata"]["sender"], "@@node1.shinkai")
self.assertEqual(result_json["external_metadata"]["recipient"], "@@node1.shinkai")
self.assertEqual(result_json["encryption"], "None")
self.assertEqual(result_json["version"], "V1_0")

if __name__ == '__main__':
unittest.main()

0 comments on commit a8c8e00

Please sign in to comment.