@@ -593,7 +593,7 @@ START_TEST(test_002InitWallet_0001SetEIP155CompSuccess)
593593 ck_assert_ptr_ne (wallet_ptr , NULL );
594594
595595 /* 1. execute unit test */
596- rtnVal = BoatEthWalletSetEIP155Comp (wallet_ptr , wallet .eip155_compatibility );
596+ rtnVal = BoatPlatONWalletSetEIP155Comp (wallet_ptr , wallet .eip155_compatibility );
597597 /* 2. verify test result */
598598 /* 2-1. verify the return value */
599599 ck_assert_int_eq (rtnVal , BOAT_SUCCESS );
@@ -610,7 +610,7 @@ START_TEST(test_002InitWallet_0002SetEIP155CompFailureNullParam)
610610 BoatPlatONWalletConfig wallet = get_platon_wallet_settings ();
611611
612612 /* 1. execute unit test */
613- rtnVal = BoatEthWalletSetEIP155Comp (NULL , wallet .eip155_compatibility );
613+ rtnVal = BoatPlatONWalletSetEIP155Comp (NULL , wallet .eip155_compatibility );
614614 /* 2. verify test result */
615615 /* 2-1. verify the return value */
616616 ck_assert_int_eq (rtnVal , BOAT_ERROR_COMMON_INVALID_ARGUMENT );
@@ -628,7 +628,7 @@ START_TEST(test_002InitWallet_0003SetChainIdSuccess)
628628 ck_assert_ptr_ne (wallet_ptr , NULL );
629629
630630 /* 1. execute unit test */
631- rtnVal = BoatEthWalletSetChainId (wallet_ptr , wallet .chain_id );
631+ rtnVal = BoatPlatONWalletSetChainId (wallet_ptr , wallet .chain_id );
632632 /* 2. verify test result */
633633 /* 2-1. verify the return value */
634634 ck_assert_int_eq (rtnVal , BOAT_SUCCESS );
@@ -645,7 +645,7 @@ START_TEST(test_002InitWallet_0004SetChainIdFailureNullParam)
645645 BoatPlatONWalletConfig wallet = get_platon_wallet_settings ();
646646
647647 /* 1. execute unit test */
648- rtnVal = BoatEthWalletSetChainId (NULL , wallet .chain_id );
648+ rtnVal = BoatPlatONWalletSetChainId (NULL , wallet .chain_id );
649649 /* 2. verify test result */
650650 /* 2-1. verify the return value */
651651 ck_assert_int_eq (rtnVal , BOAT_ERROR_COMMON_INVALID_ARGUMENT );
@@ -661,14 +661,14 @@ START_TEST(test_002InitWallet_0005SetNodeUrlSuccess)
661661
662662 /* 1. execute unit test */
663663 wallet_ptr -> network_info .node_url_ptr = NULL ;
664- rtnVal = BoatEthWalletSetNodeUrl (wallet_ptr , wallet .node_url_str );
664+ rtnVal = BoatPlatONWalletSetNodeUrl (wallet_ptr , wallet .node_url_str );
665665 /* 2. verify test result */
666666 /* 2-1. verify the return value */
667667 ck_assert_int_eq (rtnVal , BOAT_SUCCESS );
668668
669669 /* 2-2. verify the global variables that be affected */
670670 ck_assert_str_eq (wallet_ptr -> network_info .node_url_ptr , wallet .node_url_str );
671- BoatEthWalletDeInit (wallet_ptr );
671+ BoatPlatONWalletDeInit (wallet_ptr );
672672}
673673END_TEST
674674
@@ -680,7 +680,7 @@ START_TEST(test_002InitWallet_0006SetNodeUrlFailureNullParam)
680680
681681 /* 1. execute unit test */
682682 wallet_ptr -> network_info .node_url_ptr = NULL ;
683- rtnVal = BoatEthWalletSetNodeUrl (NULL , wallet .node_url_str );
683+ rtnVal = BoatPlatONWalletSetNodeUrl (NULL , wallet .node_url_str );
684684 /* 2. verify test result */
685685 /* 2-1. verify the return value */
686686 ck_assert_int_eq (rtnVal , BOAT_ERROR_COMMON_INVALID_ARGUMENT );
@@ -690,7 +690,7 @@ START_TEST(test_002InitWallet_0006SetNodeUrlFailureNullParam)
690690
691691 /* 1. execute unit test */
692692 wallet_ptr -> network_info .node_url_ptr = NULL ;
693- rtnVal = BoatEthWalletSetNodeUrl (wallet_ptr , NULL );
693+ rtnVal = BoatPlatONWalletSetNodeUrl (wallet_ptr , NULL );
694694 /* 2. verify test result */
695695 /* 2-1. verify the return value */
696696 ck_assert_int_eq (rtnVal , BOAT_ERROR_COMMON_INVALID_ARGUMENT );
@@ -700,7 +700,7 @@ START_TEST(test_002InitWallet_0006SetNodeUrlFailureNullParam)
700700
701701 /* 1. execute unit test */
702702 wallet_ptr -> network_info .node_url_ptr = NULL ;
703- rtnVal = BoatEthWalletSetNodeUrl (NULL , NULL );
703+ rtnVal = BoatPlatONWalletSetNodeUrl (NULL , NULL );
704704 /* 2. verify test result */
705705 /* 2-1. verify the return value */
706706 ck_assert_int_eq (rtnVal , BOAT_ERROR_COMMON_INVALID_ARGUMENT );
@@ -713,21 +713,21 @@ END_TEST
713713
714714START_TEST (test_002InitWallet_0007SetNodeUrlFailureErrorNodeUrlFormat )
715715{
716- // BSINT32 rtnVal;
717- // BoatPlatONWallet *wallet_ptr = BoatMalloc(sizeof(BoatPlatONWallet));
718- // BoatPlatONWalletConfig wallet;
716+ BSINT32 rtnVal ;
717+ BoatPlatONWallet * wallet_ptr = BoatMalloc (sizeof (BoatPlatONWallet ));
718+ BoatPlatONWalletConfig wallet ;
719719
720- // / * 1. execute unit test */
721- // strncpy(wallet.node_url_str, "abcd", strlen("abcd"));
722- // wallet_ptr->network_info.node_url_ptr = NULL;
723- // rtnVal = BoatEthWalletSetNodeUrl (wallet_ptr, wallet.node_url_str);
724- // / * 2. verify test result */
725- // / * 2-1. verify the return value */
726- // ck_assert_int_eq(rtnVal, BOAT_ERROR_COMMON_INVALID_ARGUMENT);
720+ /* 1. execute unit test */
721+ strncpy (wallet .node_url_str , "abcd" , strlen ("abcd" ));
722+ wallet_ptr -> network_info .node_url_ptr = NULL ;
723+ rtnVal = BoatPlatONWalletSetNodeUrl (wallet_ptr , wallet .node_url_str );
724+ /* 2. verify test result */
725+ /* 2-1. verify the return value */
726+ ck_assert_int_eq (rtnVal , BOAT_ERROR_COMMON_INVALID_ARGUMENT );
727727
728- // / * 2-2. verify the global variables that be affected */
729- // ck_assert(wallet_ptr->network_info.node_url_ptr == NULL);
730- // BoatFree(wallet_ptr);
728+ /* 2-2. verify the global variables that be affected */
729+ ck_assert (wallet_ptr -> network_info .node_url_ptr == NULL );
730+ BoatFree (wallet_ptr );
731731}
732732END_TEST
733733
@@ -744,7 +744,7 @@ START_TEST(test_002InitWallet_0008SetNodeUrlFailureNodeUrlOutOfLimit)
744744
745745 /* 1. execute unit test */
746746 wallet_ptr -> network_info .node_url_ptr = NULL ;
747- rtnVal = BoatEthWalletSetNodeUrl (wallet_ptr , error_platon_node_url );
747+ rtnVal = BoatPlatONWalletSetNodeUrl (wallet_ptr , error_platon_node_url );
748748 /* 2. verify test result */
749749 /* 2-1. verify the return value */
750750 ck_assert_int_eq (rtnVal , BOAT_ERROR_COMMON_INVALID_ARGUMENT );
@@ -760,7 +760,7 @@ START_TEST(test_002InitWallet_0009InitPlatONWalletWithNullConfig)
760760 BoatPlatONWallet * rtnVal ;
761761
762762 /* 1. execute unit test */
763- rtnVal = BoatEthWalletInit (NULL , sizeof (BoatPlatONWalletConfig ));
763+ rtnVal = BoatPlatONWalletInit (NULL , sizeof (BoatPlatONWalletConfig ));
764764 /* 2. verify test result */
765765 /* 2-1. verify the return value */
766766 ck_assert_ptr_eq (rtnVal ,NULL );
@@ -775,7 +775,7 @@ START_TEST(test_002InitWallet_0010InitPlatONWalletWithSmallerSize)
775775 BoatPlatONWalletConfig walletConfig = {0 };
776776
777777 /* 1. execute unit test */
778- rtnVal = BoatEthWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ) - 1 );
778+ rtnVal = BoatPlatONWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ) - 1 );
779779 /* 2. verify test result */
780780 /* 2-1. verify the return value */
781781 ck_assert_ptr_eq (rtnVal ,NULL );
@@ -790,7 +790,7 @@ START_TEST(test_002InitWallet_0011InitPlatONWalletWithBiggerSize)
790790 BoatPlatONWalletConfig walletConfig = {0 };
791791
792792 /* 1. execute unit test */
793- rtnVal = BoatEthWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ) + 1 );
793+ rtnVal = BoatPlatONWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ) + 1 );
794794 /* 2. verify test result */
795795 /* 2-1. verify the return value */
796796 ck_assert_ptr_eq (rtnVal ,NULL );
@@ -805,7 +805,7 @@ START_TEST(test_002InitWallet_0012InitPlatONWalletSuccess)
805805 BoatPlatONWalletConfig walletConfig = get_platon_wallet_settings ();
806806
807807 /* 1. execute unit test */
808- rtnVal = BoatEthWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
808+ rtnVal = BoatPlatONWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
809809 /* 2. verify test result */
810810 /* 2-1. verify the return value */
811811 ck_assert_ptr_ne (rtnVal ,NULL );
@@ -825,11 +825,11 @@ START_TEST(test_002InitWallet_0013InitPlatONWalletGenerationKey)
825825 walletConfig .eip155_compatibility = BOAT_FALSE ;
826826
827827 /* 1. execute unit test */
828- rtnVal = BoatEthWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
828+ rtnVal = BoatPlatONWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
829829 /* 2. verify test result */
830830 /* 2-1. verify the return value */
831831 ck_assert_ptr_ne (rtnVal ,NULL );
832-
832+ BoatPlatONWalletDeInit ( rtnVal );
833833 /* 2-2. verify the global variables that be affected */
834834}
835835END_TEST
@@ -846,7 +846,7 @@ START_TEST(test_002InitWallet_0014InitPlatONWalletWithWrongGenMode)
846846 walletConfig .load_existed_wallet = BOAT_FALSE ;
847847
848848 /* 1. execute unit test */
849- rtnVal = BoatEthWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
849+ rtnVal = BoatPlatONWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
850850 /* 2. verify test result */
851851 /* 2-1. verify the return value */
852852 ck_assert_ptr_eq (rtnVal ,NULL );
@@ -855,34 +855,38 @@ END_TEST
855855
856856START_TEST (test_002InitWallet_0015InitPlatONWalletWithWrongKeyFormat )
857857{
858+ BoatLog (BOAT_LOG_VERBOSE , "test_002InitWallet_0015InitPlatONWalletWithWrongKeyFormat" );
858859 BoatPlatONWallet * rtnVal ;
859860 BoatPlatONWalletConfig walletConfig ;
860861
861862 walletConfig .prikeyCtx_config .prikey_genMode = BOAT_WALLET_PRIKEY_GENMODE_INTERNAL_GENERATION ;
862863 walletConfig .prikeyCtx_config .prikey_format = 4 ;
863864 walletConfig .prikeyCtx_config .prikey_type = BOAT_WALLET_PRIKEY_TYPE_SECP256K1 ;
864865 walletConfig .eip155_compatibility = BOAT_FALSE ;
866+ walletConfig .load_existed_wallet = BOAT_FALSE ;
865867
866868 /* 1. execute unit test */
867- rtnVal = BoatEthWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
869+ rtnVal = BoatPlatONWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
868870 /* 2. verify test result */
869871 /* 2-1. verify the return value */
870- ck_assert_ptr_ne (rtnVal ,NULL );
872+ ck_assert_ptr_eq (rtnVal ,NULL );
871873}
872874END_TEST
873875
874876START_TEST (test_002InitWallet_0016InitPlatONWalletWithWrongType )
875877{
878+ BoatLog (BOAT_LOG_VERBOSE , "test_002InitWallet_0016InitPlatONWalletWithWrongType" );
876879 BoatPlatONWallet * rtnVal ;
877880 BoatPlatONWalletConfig walletConfig ;
878881
879882 walletConfig .prikeyCtx_config .prikey_genMode = BOAT_WALLET_PRIKEY_GENMODE_INTERNAL_GENERATION ;
880883 walletConfig .prikeyCtx_config .prikey_format = BOAT_WALLET_PRIKEY_FORMAT_NATIVE ;
881884 walletConfig .prikeyCtx_config .prikey_type = 3 ;
882885 walletConfig .eip155_compatibility = BOAT_FALSE ;
886+ walletConfig .load_existed_wallet = BOAT_FALSE ;
883887
884888 /* 1. execute unit test */
885- rtnVal = BoatEthWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
889+ rtnVal = BoatPlatONWalletInit (& walletConfig , sizeof (BoatPlatONWalletConfig ));
886890 /* 2. verify test result */
887891 /* 2-1. verify the return value */
888892 ck_assert_ptr_eq (rtnVal ,NULL );
@@ -891,8 +895,22 @@ END_TEST
891895
892896START_TEST (test_003DeleteWallet_0001DeleteWalletFailureNullFleName )
893897{
898+ BSINT32 rtnVal ;
899+
900+ BoatIotSdkInit ();
901+ BoatPlatONWalletConfig wallet = get_platon_wallet_settings ();
902+ extern BoatIotSdkContext g_boat_iot_sdk_context ;
903+
904+ /* 1. execute unit test */
905+ rtnVal = BoatWalletCreate (BOAT_PROTOCOL_PLATON , "platon" , & wallet , sizeof (BoatPlatONWalletConfig ));
906+
907+ /* 2. verify test result */
908+ /* 2-1. verify the return value */
909+ ck_assert_int_eq (rtnVal , 0 );
910+
894911 BoatWalletDelete (NULL );
895912 ck_assert_int_eq (access ("platon" , F_OK ), 0 );
913+ BoatIotSdkDeInit ();
896914}
897915END_TEST
898916
@@ -918,6 +936,8 @@ Suite *make_wallet_suite(void)
918936 /* Create test cases */
919937 TCase * tc_wallet_api = tcase_create ("wallet_api" );
920938
939+ tcase_set_timeout (tc_wallet_api ,50 );
940+
921941 /* Add a test case to the Suite */
922942 suite_add_tcase (s_wallet , tc_wallet_api );
923943 /* Test cases are added to the test set */
0 commit comments