Skip to content

Commit

Permalink
chore: add error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reez committed May 1, 2024
1 parent 6522dfd commit c42f8b9
Show file tree
Hide file tree
Showing 2 changed files with 996 additions and 590 deletions.
132 changes: 66 additions & 66 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ namespace bdk {};
// ------------------------------------------------------------------------

[Error]
interface Bip39Error {
BadWordCount(u64 word_count);
UnknownWord(u64 index);
BadEntropyBitCount(u64 bit_count);
InvalidChecksum();
AmbiguousLanguages(string languages);
interface AddressError {
Base58();
Bech32();
WitnessVersion(string error_message);
WitnessProgram(string error_message);
UncompressedPubkey();
ExcessiveScriptSize();
UnrecognizedScript();
NetworkValidation(Network required, Network found, string address);
OtherAddressErr();
};

[Error]
Expand All @@ -29,10 +33,12 @@ interface Bip32Error {
};

[Error]
interface DescriptorKeyError {
Parse(string e);
InvalidKeyType();
Bip32(string e);
interface Bip39Error {
BadWordCount(u64 word_count);
UnknownWord(u64 index);
BadEntropyBitCount(u64 bit_count);
InvalidChecksum();
AmbiguousLanguages(string languages);
};

[Error]
Expand All @@ -42,15 +48,8 @@ interface CalculateFeeError {
};

[Error]
interface WalletCreationError {
Io(string e);
InvalidMagicBytes(sequence<u8> got, sequence<u8> expected);
Descriptor();
Write();
Load();
NotInitialized();
LoadedGenesisDoesNotMatch();
LoadedNetworkDoesNotMatch(Network expected, Network? got);
interface CannotConnectError {
Include(u32 height);
};

[Error]
Expand Down Expand Up @@ -80,8 +79,26 @@ interface CreateTxError {
};

[Error]
interface PersistenceError {
Write(string e);
interface DescriptorError {
InvalidHdKeyPath();
InvalidDescriptorChecksum();
HardenedDerivationXpub();
MultiPath();
Key(string e);
Policy(string e);
InvalidDescriptorCharacter(string char);
Bip32(string e);
Base58(string e);
Pk(string e);
Miniscript(string e);
Hex(string e);
};

[Error]
interface DescriptorKeyError {
Parse(string e);
InvalidKeyType();
Bip32(string e);
};

[Error]
Expand All @@ -101,32 +118,21 @@ interface EsploraError {
};

[Error]
enum FeeRateError {
"ArithmeticOverflow"
interface ExtractTxError {
AbsurdFeeRate(u64 fee_rate);
MissingInputValue();
SendingTooMuch();
OtherExtractTxErr();
};

[Error]
interface AddressError {
Base58();
Bech32();
WitnessVersion(string error_message);
WitnessProgram(string error_message);
UncompressedPubkey();
ExcessiveScriptSize();
UnrecognizedScript();
NetworkValidation(Network required, Network found, string address);
OtherAddressErr();
enum FeeRateError {
"ArithmeticOverflow"
};

[Error]
interface TransactionError {
Io();
OversizedVectorAllocation();
InvalidChecksum(string expected, string actual);
NonMinimalVarInt();
ParseFailed();
UnsupportedSegwitFlag(u8 flag);
OtherTransactionErr();
interface PersistenceError {
Write(string e);
};

[Error]
Expand All @@ -135,22 +141,6 @@ interface PsbtParseError {
Base64Encoding(string e);
};

[Error]
interface DescriptorError {
InvalidHdKeyPath();
InvalidDescriptorChecksum();
HardenedDerivationXpub();
MultiPath();
Key(string e);
Policy(string e);
InvalidDescriptorCharacter(string char);
Bip32(string e);
Base58(string e);
Pk(string e);
Miniscript(string e);
Hex(string e);
};

[Error]
interface SignerError {
MissingKey();
Expand All @@ -170,21 +160,31 @@ interface SignerError {
};

[Error]
interface TxidParseError {
InvalidTxid(string txid);
interface TransactionError {
Io();
OversizedVectorAllocation();
InvalidChecksum(string expected, string actual);
NonMinimalVarInt();
ParseFailed();
UnsupportedSegwitFlag(u8 flag);
OtherTransactionErr();
};

[Error]
interface ExtractTxError {
AbsurdFeeRate(u64 fee_rate);
MissingInputValue();
SendingTooMuch();
OtherExtractTxErr();
interface TxidParseError {
InvalidTxid(string txid);
};

[Error]
interface CannotConnectError {
Include(u32 height);
interface WalletCreationError {
Io(string e);
InvalidMagicBytes(sequence<u8> got, sequence<u8> expected);
Descriptor();
Write();
Load();
NotInitialized();
LoadedGenesisDoesNotMatch();
LoadedNetworkDoesNotMatch(Network expected, Network? got);
};

// ------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit c42f8b9

Please sign in to comment.