Skip to content

Commit

Permalink
fix: making amount msatoshi field optional
Browse files Browse the repository at this point in the history
  • Loading branch information
KAVAN-DESAI authored and vincenzopalazzo committed Jul 19, 2022
1 parent f28f7a5 commit eeff1cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions example/cln_grpc_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PayProxy extends Serializable {

PayProxy(this.proxy);

factory PayProxy.build(String invoice, Amount? amount) =>
factory PayProxy.build({required String invoice, Amount? amount}) =>
PayProxy(PayRequest(bolt11: invoice, msatoshi: amount));

@override
Expand Down Expand Up @@ -58,7 +58,7 @@ Future<void> main(List<String> args) async {
amount.msat = msat;
String boltString = args[1];
var pay = await client.call<PayProxy, PayResponse>(
method: "pay", params: PayProxy.build(boltString, amount));
method: "pay", params: PayProxy.build(invoice: boltString));

print(pay.amountMsat.msat);
client.close();
Expand Down
14 changes: 5 additions & 9 deletions test/cln_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:io';
import 'package:clightning_rpc/clightning_rpc.dart';
import 'package:cln_common/cln_common.dart';
import 'package:cln_grpc/cln_grpc.dart';
import 'package:fixnum/fixnum.dart';
import 'package:grpc/grpc.dart';
import 'package:test/test.dart';

Expand Down Expand Up @@ -69,7 +68,7 @@ class PayProxy extends Serializable {

PayProxy(this.proxy);

factory PayProxy.build(String invoice, Amount? amount) =>
factory PayProxy.build({required String invoice, Amount? amount}) =>
PayProxy(PayRequest(bolt11: invoice, msatoshi: amount));

@override
Expand Down Expand Up @@ -143,31 +142,28 @@ void main() {
await client.close();
});

/// FIXME: need some improvement in pay service test
test('call pay through generic client', () async {
// Get an invoice with Unix RPC client
/// Get an invoice with Unix RPC client
var unixCient = RPCClient().connect(rpcPath!);

var client = GRPCClient(rootPath: tlsPath);
Int64 msat = Int64(1000);
Amount amount = Amount();
amount.msat = msat;

var params = <String, dynamic>{
'msatoshi': '100000msat',
'label': 'from-grpc_dart-1',
'description': 'This is a integration test'
};

var boltString = await unixCient.simpleCall("invoice", params: params);
try {
var response = await client.call<PayProxy, PayResponse>(
method: "pay",
params: PayProxy.build(boltString["bolt11"], amount));
params: PayProxy.build(invoice: boltString["bolt11"]));
await client.close();
fail("No exception received and this is stange");
} on GrpcError catch (ex) {
expect(ex.message,
"This payment is destined for ourselves. Self-payments are not supported");
'''Error calling method Pay: RpcError { code: Some(-32602), message: "This payment is destined for ourselves. Self-payments are not supported" }''');
} catch (ex) {
fail("$ex");
}
Expand Down

0 comments on commit eeff1cb

Please sign in to comment.