Skip to content

Setter and recipient must be the same person #755

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

Merged
merged 1 commit into from
Apr 15, 2020
Merged
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
16 changes: 7 additions & 9 deletions common/query/accountDatasetQuery.go
Original file line number Diff line number Diff line change
@@ -20,9 +20,7 @@ type (
GetLatestAccountDataset(setterAccountAddress, recipientAccountAddress, property string) (str string, args []interface{})
InsertAccountDataset(dataset *model.AccountDataset) (str string, args []interface{})
RemoveAccountDataset(dataset *model.AccountDataset) [][]interface{}
GetAccountDatasetEscrowApproval(
recipientAccountAddress string,
) (qStr string, args []interface{})
GetAccountDatasetEscrowApproval(accountAddress string) (qStr string, args []interface{})
ExtractModel(dataset *model.AccountDataset) []interface{}
BuildModel(datasets []*model.AccountDataset, rows *sql.Rows) ([]*model.AccountDataset, error)
Scan(dataset *model.AccountDataset, row *sql.Row) error
@@ -107,16 +105,16 @@ func (adq *AccountDatasetQuery) RemoveAccountDataset(dataset *model.AccountDatas
}

// GetAccountDatasetEscrowApproval represents query for get account dataset for AccountDatasetEscrowApproval property
func (adq *AccountDatasetQuery) GetAccountDatasetEscrowApproval(
recipientAccountAddress string,
) (qStr string, args []interface{}) {
// SetterAccountAddress and RecipientAccountAddress must be the same person
func (adq *AccountDatasetQuery) GetAccountDatasetEscrowApproval(accountAddress string) (qStr string, args []interface{}) {
return fmt.Sprintf(
"SELECT %s FROM %s WHERE recipient_account_address = ? AND property = ? AND latest = ?",
"SELECT %s FROM %s WHERE setter_account_address = ? AND recipient_account_address = ? AND property = ? AND latest = ?",
strings.Join(adq.Fields, ", "),
adq.getTableName(),
), []interface{}{
recipientAccountAddress,
"AccountDatasetEscrowApproval",
accountAddress,
accountAddress,
model.AccountDatasetProperty_AccountDatasetEscrowApproval.String(),
1,
}
}
9 changes: 5 additions & 4 deletions common/query/accountDatasetQuery_test.go
Original file line number Diff line number Diff line change
@@ -196,7 +196,7 @@ func TestAccountDatasetsQuery_GetAccountDatasetEscrowApproval(t *testing.T) {
TableName string
}
type args struct {
recipientAccountAddress string
accountAddress string
}
tests := []struct {
name string
@@ -208,10 +208,11 @@ func TestAccountDatasetsQuery_GetAccountDatasetEscrowApproval(t *testing.T) {
{
name: "wantSuccess",
fields: fields(*mockDatasetQuery),
args: args{recipientAccountAddress: "BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN"},
args: args{accountAddress: "BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN"},
wantQStr: "SELECT setter_account_address, recipient_account_address, property, value, is_active, latest, height FROM account_dataset " +
"WHERE recipient_account_address = ? AND property = ? AND latest = ?",
"WHERE setter_account_address = ? AND recipient_account_address = ? AND property = ? AND latest = ?",
wantArgs: []interface{}{
"BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN",
"BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN",
"AccountDatasetEscrowApproval",
1,
@@ -224,7 +225,7 @@ func TestAccountDatasetsQuery_GetAccountDatasetEscrowApproval(t *testing.T) {
Fields: tt.fields.Fields,
TableName: tt.fields.TableName,
}
gotQStr, gotArgs := adq.GetAccountDatasetEscrowApproval(tt.args.recipientAccountAddress)
gotQStr, gotArgs := adq.GetAccountDatasetEscrowApproval(tt.args.accountAddress)
if gotQStr != tt.wantQStr {
t.Errorf("GetAccountDatasetEscrowApproval() gotQStr = \n%v, want \n%v", gotQStr, tt.wantQStr)
return