-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove prefix from QR code scans (#121)
* Remove prefix from QR code scans * Remove query parameters from address and parse amount Did not modify PaymentUriInfo to avoid issues with segwit variants
- Loading branch information
1 parent
571a223
commit 3dffc55
Showing
3 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:komodo_dex/model/coin.dart'; | ||
import 'package:komodo_dex/utils/utils.dart'; | ||
|
||
void main() { | ||
group('removeBlockchainPrefix', () { | ||
test('removes blockchain prefix from address', () { | ||
const String address = 'eth:0x1234567890abcdef'; | ||
final String result = getAddressFromUri(address); | ||
expect(result, '0x1234567890abcdef'); | ||
}); | ||
|
||
test('removes blackcoin prefix from address', () { | ||
const String address = 'blackcoin:B8Q9aZ4Mz1ZwWYaknJdZ8t3Z6z9F3Fz1Zz'; | ||
final String result = getAddressFromUri(address); | ||
expect(result, 'B8Q9aZ4Mz1ZwWYaknJdZ8t3Z6z9F3Fz1Zz'); | ||
}); | ||
|
||
test('returns the same address if no prefix is present', () { | ||
const String address = '0x1234567890abcdef'; | ||
final String result = getAddressFromUri(address); | ||
expect(result, '0x1234567890abcdef'); | ||
}); | ||
}); | ||
|
||
group('getParameterValue', () { | ||
test('returns the parameter value from the address', () { | ||
const String address = | ||
'eth:0x1234567890abcdef?param1=value1¶m2=value2'; | ||
const String parameter = 'param1'; | ||
final String result = getParameterValue(address, parameter); | ||
expect(result, 'value1'); | ||
}); | ||
|
||
test('returns null if the parameter is not present in the address', () { | ||
const String address = | ||
'eth:0x1234567890abcdef?param1=value1¶m2=value2'; | ||
const String parameter = 'param3'; | ||
final String result = getParameterValue(address, parameter); | ||
expect(result, isNull); | ||
}); | ||
|
||
test('returns null if the address does not contain any parameters', () { | ||
const String address = 'eth:0x1234567890abcdef'; | ||
const String parameter = 'param1'; | ||
final String result = getParameterValue(address, parameter); | ||
expect(result, isNull); | ||
}); | ||
}); | ||
} |