Skip to content

Commit

Permalink
hardcoded whitelist to uuid: bluzelle key: bluzelle, removed print st…
Browse files Browse the repository at this point in the history
…atements
  • Loading branch information
avendauz committed Aug 13, 2021
1 parent 986fc71 commit 82191e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
12 changes: 6 additions & 6 deletions app/ante/NewSetUpContextDecorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit uint64, tx sdk.Tx, gk
feePayer := feeTx.FeePayer()

whiteList := getWhitelist(ctx, crudKeeper)
fmt.Println("WHITELIST", whiteList)

msgModule := tx.GetMsgs()[0].Route()
fmt.Println("MSGMODULE", msgModule)

isOnWhiteListAndFree := isOnWhiteListAndFree(msgModule, feePayer.String(), whiteList)
fmt.Println("FEE PAYER", feePayer.String())
fmt.Println(isOnWhiteListAndFree)


if gasPriceCoins.AmountOf("ubnt").LT(minGasPriceCoins.AmountOf("ubnt")) {
return ctx, sdkerrors.New("curium", 2, "Specified gas price too low")
}


if isOnWhiteListAndFree {
fmt.Println("ON WHITE LIST, ASSIGNING GAS METER")

gm := gasmeter.NewFreeGasMeter(gasLimit)
gk.AddGasMeter(&gm)
return ctx.WithGasMeter(gm), nil
Expand All @@ -144,7 +144,7 @@ func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit uint64, tx sdk.Tx, gk
func getWhitelist (ctx sdk.Context, crudKeeper crud.Keeper) (string) {
store := crudKeeper.GetKVStore(ctx)

whiteList := crudKeeper.GetValue(ctx, store, "uuid", "WHITELIST")
whiteList := crudKeeper.GetValue(ctx, store, "bluzelle", "bluzelle")

return whiteList.Value
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/helpers/nft-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const getAPIAndSwarm = (config: SwarmConfig = mattnetConfig, reimage: boo
.then(mnemonic => bluzelle({
mnemonic,
endpoint: getSentryUrl(),
uuid: "uuid",
uuid: "bluzelle",
}))
.then(bz => ({
bz,
Expand Down
21 changes: 14 additions & 7 deletions test/integration/specs/nft/whitelist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('whitelist', function() {
this.timeout(6000000);
let bz: API

beforeEach(() => getAPIAndSwarm(mattnetConfig, true)
beforeEach(() => getAPIAndSwarm(mattnetConfig)
.then(({bz: newBz}) => bz = newBz)
)
// beforeEach(() =>
Expand All @@ -34,17 +34,17 @@ describe('whitelist', function() {


it('should not charge for accounts on the whitelist', () => {
return bz.create("WHITELIST", bz.address, defaultGasParams())
return createWhiteList(bz, bz.address)
.then(() => checkGasChargeIsZero(bz, "myNftId"))
});

it('should not charge for all accounts on the whitelist', () => {
return Promise.all<API>(times(5).map(() =>
return Promise.all<API>(times(2).map(() =>
createMintedBz()
))
.then(passThroughAwait((clients : API[]) =>
Promise.all(clients.map(client => client.address))
.then(addresses => bz.create("WHITELIST", addresses.toString(), defaultGasParams())
.then(addresses => createWhiteList(bz, addresses.toString())
)))
.then((clients: API[]) => Promise.all(clients.map((client, idx) => checkGasChargeIsZero(client, `nft-id-${idx}`))))

Expand All @@ -56,20 +56,24 @@ describe('whitelist', function() {
))
.then(passThroughAwait((clients : API[]) =>
Promise.all(clients.map(client => client.address))
.then(addresses => bz.create("WHITELIST", addresses.toString(), defaultGasParams())
.then(addresses => createWhiteList(bz, addresses.toString())
)))
.then(() => createBz(bz))
.then(newBz => checkGasWasCharged(newBz, "newBzId"))
});

it("should charge everybody if whitelist is empty", () => {
return Promise.all<API>(times(5).map(() =>
return Promise.all<API>(times(2).map(() =>
createMintedBz()
))
.then((clients: API[]) => Promise.all(clients.map((client, idx) => checkGasWasCharged(client, `nft-id-${idx}`))))

});

it('should charge for createNft by non-whitelisted user', () => {
return checkGasWasCharged(bz, "myNftId")
})



});
Expand Down Expand Up @@ -110,4 +114,7 @@ const checkGasWasCharged = (bz: API, id: string): Promise<void> => {
))
.then(() => bz.getBNT({ubnt: true}))
.then(remainingBal => expect(remainingBal).to.be.lessThan(originalBal))
}
}

const createWhiteList = (bz: API, addresses: string): Promise<unknown> =>
bz.create("bluzelle", addresses, defaultGasParams())

0 comments on commit 82191e6

Please sign in to comment.