Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isseu 374: Sender can also be a potential signer #375

Merged
merged 5 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions escrow/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func (validator *ChannelPaymentValidator) Validate(payment *Payment, channel *Pa
}

log = log.WithField("signerAddress", blockchain.AddressToHex(signerAddress))
if *signerAddress != channel.Signer {
log.WithField("signerAddress", blockchain.AddressToHex(signerAddress)).Warn("Channel signer is not equal to payment signer")
return NewPaymentError(Unauthenticated, "payment is not signed by channel signer")
if *signerAddress != channel.Signer && *signerAddress != channel.Sender {
log.WithField("signerAddress", blockchain.AddressToHex(signerAddress)).Warn("Channel signer is not equal to payment signer/sender")
return NewPaymentError(Unauthenticated, "payment is not signed by channel signer/sender")
}
currentBlock, e := validator.currentBlock()
if e != nil {
Expand Down
2 changes: 1 addition & 1 deletion escrow/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (suite *ValidationTestSuite) TestValidatePaymentIncorrectSigner() {

err := suite.validator.Validate(payment, suite.channel())

assert.Equal(suite.T(), NewPaymentError(Unauthenticated, "payment is not signed by channel signer"), err)
assert.Equal(suite.T(), NewPaymentError(Unauthenticated, "payment is not signed by channel signer/sender"), err)
}

func (suite *ValidationTestSuite) TestValidatePaymentChannelCannotGetCurrentBlock() {
Expand Down
9 changes: 8 additions & 1 deletion ratelimit/rateLimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/singnet/snet-daemon/config"
"golang.org/x/time/rate"
"math"
"strconv"
"time"
)

Expand All @@ -19,7 +20,13 @@ func NewRateLimiter() rate.Limiter {
}

func getLimit() rate.Limit {
ratePerMin := config.GetInt(config.RateLimitPerMinute)


ratePerMin, err := strconv.ParseFloat(config.GetString(config.RateLimitPerMinute), 32)
if err != nil {
return rate.Inf
}

//If the rate limit parameter Value is not defined we will assume it to be Infinity ( no Rate Limiting) ,
if ratePerMin == 0 {
return rate.Inf
Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ for d in */ ; do
done
echo "mode: set">>coverage.out
grep -h -v "mode: set" *.part >>coverage.out
# /go/bin/goveralls -coverprofile=coverage.out -service=circleci -repotoken ${COVERALLS_REPO_TOKEN}
/go/bin/goveralls -coverprofile=coverage.out -service=circleci -repotoken ${COVERALLS_REPO_TOKEN}
popd