storj/satellite/payments/stripecoinpayments/accounts_test.go
Bill Thorp b265b7f555 satellite/console: make paywall optional
Add a config so that some percent of users require credit cards /
account balances
in order to create a project or have a promotional coupon applied

UI was updated to match needed paywall status

At this point we decided not to use a field to store if a user is in an
A/B
test, and instead just use math to see if they're in a test.  We decided
to use MD5 (because its in Postgres too) and User UUID for that math.

Change-Id: I0fcd80707dc29afc668632d078e1b5a7a24f3bb3
2020-07-28 10:57:49 +00:00

40 lines
1.4 KiB
Go

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package stripecoinpayments_test
import (
"testing"
"github.com/stretchr/testify/assert"
"storj.io/common/uuid"
"storj.io/storj/satellite/payments/stripecoinpayments"
)
func TestBytesAreWithinProportion(t *testing.T) {
f := stripecoinpayments.BytesAreWithinProportion
assert.False(t, f(uuid.UUID{0}, 0.0))
assert.False(t, f(uuid.UUID{255}, 0.25))
assert.False(t, f(uuid.UUID{192}, 0.25))
assert.False(t, f(uuid.UUID{128}, 0.25))
assert.False(t, f(uuid.UUID{64}, 0.25))
assert.True(t, f(uuid.UUID{63, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, 0.25))
assert.True(t, f(uuid.UUID{32}, 0.25))
assert.False(t, f(uuid.UUID{129}, 0.5))
assert.False(t, f(uuid.UUID{128}, 0.5))
assert.True(t, f(uuid.UUID{127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, 0.5))
assert.True(t, f(uuid.UUID{127}, 0.5))
assert.False(t, f(uuid.UUID{255}, 0.75))
assert.False(t, f(uuid.UUID{192}, 0.75))
assert.True(t, f(uuid.UUID{191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, 0.75))
assert.True(t, f(uuid.UUID{128}, 0.75))
assert.True(t, f(uuid.UUID{64}, 0.75))
assert.True(t, f(uuid.UUID{32}, 0.75))
assert.True(t, f(uuid.UUID{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, 1.0))
}