mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
move test function to a test
This commit is contained in:
parent
06b964a728
commit
ee88cd8fb0
2 changed files with 40 additions and 37 deletions
|
@ -272,43 +272,6 @@ ParsedOutput unwrap_spk(Uint8List wrapped_spk) {
|
|||
return parsedOutput;
|
||||
}
|
||||
|
||||
|
||||
// Just a testing function which can be called in standalone fashion.
|
||||
// Replace "var1" with a hex string containing an output (script pub key)
|
||||
void testUnwrapSPK() {
|
||||
|
||||
|
||||
// Example Hex format string
|
||||
String var1 = "YOUR-SCRIPT-PUBKEY-AS-HEX-STRING-FOR-TESTING-GOES-HERE";
|
||||
// Convert the Hex string to Uint8List
|
||||
Uint8List wrapped_spk = Uint8List.fromList(HEX.decode(var1));
|
||||
|
||||
// Call unwrap_spk
|
||||
ParsedOutput parsedOutput = unwrap_spk(wrapped_spk);
|
||||
|
||||
print("Parsed Output: $parsedOutput");
|
||||
|
||||
// Access token_data inside parsedOutput
|
||||
TokenOutputData? tokenData = parsedOutput.token_data;
|
||||
|
||||
// Check if tokenData is null
|
||||
if (tokenData != null) {
|
||||
// Print specific fields
|
||||
if (tokenData.id != null) {
|
||||
print("ID: ${hex.encode(tokenData.id!)}"); // hex is imported
|
||||
} else {
|
||||
print("ID: null");
|
||||
}
|
||||
print ("amount of tokens");
|
||||
print (tokenData.amount);
|
||||
print("Is it an NFT?: ${tokenData.hasNFT()}");
|
||||
} else {
|
||||
print("Token data is null.");
|
||||
}
|
||||
|
||||
} //end function
|
||||
|
||||
|
||||
// HELPER FUNCTIONS
|
||||
|
||||
//These are part of a "length value " scheme where the length (and endianness) are given first
|
||||
|
|
40
test/services/coins/bitcoincash/cashtokens_test.dart
Normal file
40
test/services/coins/bitcoincash/cashtokens_test.dart
Normal file
|
@ -0,0 +1,40 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:convert/convert.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hex/hex.dart';
|
||||
import 'package:stackwallet/services/coins/bitcoincash/cashtokens.dart';
|
||||
|
||||
void main() {
|
||||
// Just a testing function which can be called in standalone fashion.
|
||||
// Replace "var1" with a hex string containing an output (script pub key)
|
||||
test("testUnwrapSPK", () {
|
||||
// Example Hex format string
|
||||
String var1 = "YOUR-SCRIPT-PUBKEY-AS-HEX-STRING-FOR-TESTING-GOES-HERE";
|
||||
// Convert the Hex string to Uint8List
|
||||
Uint8List wrapped_spk = Uint8List.fromList(HEX.decode(var1));
|
||||
|
||||
// Call unwrap_spk
|
||||
ParsedOutput parsedOutput = unwrap_spk(wrapped_spk);
|
||||
|
||||
print("Parsed Output: $parsedOutput");
|
||||
|
||||
// Access token_data inside parsedOutput
|
||||
TokenOutputData? tokenData = parsedOutput.token_data;
|
||||
|
||||
// Check if tokenData is null
|
||||
if (tokenData != null) {
|
||||
// Print specific fields
|
||||
if (tokenData.id != null) {
|
||||
print("ID: ${hex.encode(tokenData.id!)}"); // hex is imported
|
||||
} else {
|
||||
print("ID: null");
|
||||
}
|
||||
print("amount of tokens");
|
||||
print(tokenData.amount);
|
||||
print("Is it an NFT?: ${tokenData.hasNFT()}");
|
||||
} else {
|
||||
print("Token data is null.");
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue