diff --git a/contracts/src/Payment.sol b/contracts/src/Payment.sol index 21af600b..fd13ea7a 100644 --- a/contracts/src/Payment.sol +++ b/contracts/src/Payment.sol @@ -62,6 +62,8 @@ contract Payment { address publisher = msg.sender; Channel storage channel = channels[publisher][provider][podId]; + if (channel.investedByPublisher == 0) revert DoesNotExist(); + channel.investedByPublisher = channel.investedByPublisher + amount; channel.unlockedAt = 0; diff --git a/contracts/test/Payment.t.sol b/contracts/test/Payment.t.sol index a9e1d742..21711fc5 100644 --- a/contracts/test/Payment.t.sol +++ b/contracts/test/Payment.t.sol @@ -45,6 +45,9 @@ contract PaymentTest is Test { token.mint(1000); token.approve(address(payment), 500); + vm.expectRevert(Payment.DoesNotExist.selector); + payment.deposit(provider, podId, 500); + payment.createChannel(provider, podId, 1, 500); token.approve(address(payment), 500);