Skip to content

Commit 52669cd

Browse files
committed
WIP
1 parent 07fc465 commit 52669cd

File tree

3 files changed

+15
-37
lines changed

3 files changed

+15
-37
lines changed

config/database.rules.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"rules": {
33
".read": true,
4-
".write": true
4+
".write": true,
5+
"testing": {
6+
".indexOn": "lease"
7+
}
58
}
69
}

packages/database-compat/test/query.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4687,16 +4687,25 @@ describe('Query Tests', () => {
46874687
await root
46884688
.child('i|3')
46894689
.set({ lease: 2, timestamp: Date.now(), action: 'test' });
4690-
query.on('child_added', snap => {
4690+
const childAdded = query.on('child_added', snap => {
46914691
const value = snap.val();
4692+
console.log('onChildAdded', value);
4693+
if(value.timestamp && !value.lease) {
4694+
console.log("ERR: missing value");
4695+
}
46924696
expect(value).to.haveOwnProperty('timestamp');
46934697
expect(value).to.haveOwnProperty('action');
4698+
expect(value).to.haveOwnProperty('lease');
46944699
});
4695-
root.child('i|1').on('value', snap => {
4700+
const onValue = root.child('i|1').on('value', snap => {
4701+
console.log('onValue', snap.val());
46964702
//no-op
46974703
});
46984704
await root.child('i|1').update({ timestamp: `${Date.now()}|1` });
4705+
console.log('wrote value');
46994706
await new Promise(resolve => setTimeout(resolve, 4000));
4707+
root.child('i|1').off('value', onValue);
4708+
query.off('child_added', childAdded);
47004709
});
47014710

47024711
it('Can JSON serialize refs', () => {

packages/database-compat/test/transaction.test.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { _TEST_ACCESS_hijackHash as hijackHash } from '@firebase/database';
2020
import { Deferred } from '@firebase/util';
2121
import { expect } from 'chai';
2222

23-
import { Path } from '../../database/src/core/util/Path';
2423
import {
2524
EventAccumulator,
2625
EventAccumulatorFactory
@@ -30,9 +29,7 @@ import { Reference } from '../src/api/Reference';
3029
import { eventTestHelper } from './helpers/events';
3130
import {
3231
canCreateExtraConnections,
33-
getFreshRepo,
3432
getFreshRepoFromReference,
35-
getPath,
3633
getRandomNode,
3734
getVal
3835
} from './helpers/util';
@@ -1533,35 +1530,4 @@ describe('Transaction Tests', () => {
15331530
await incrementViaTransaction();
15341531
expect(latestValue).to.equal(2);
15351532
});
1536-
it.only('can send valid input with concurrent writes', async () => {
1537-
const rwRef = getFreshRepo(new Path('/')) as Reference;
1538-
const wRef = getFreshRepo(new Path('/')) as Reference;
1539-
async function runTransactions() {
1540-
while (1) {
1541-
console.log(getPath(rwRef));
1542-
await rwRef.child('abc').transaction((data: any) => {
1543-
console.log(data);
1544-
if (data) {
1545-
expect(!!data.test && !!data.timestamp).to.be.true;
1546-
}
1547-
return data;
1548-
});
1549-
await new Promise(resolve => setTimeout(resolve, 150));
1550-
}
1551-
console.log('done read');
1552-
}
1553-
async function runWrites() {
1554-
console.log(getPath(wRef));
1555-
while (1) {
1556-
await wRef.child('abc').set({
1557-
test: 'abc',
1558-
timestamp: Date.now()
1559-
});
1560-
}
1561-
console.log('done writing');
1562-
}
1563-
runWrites();
1564-
runTransactions();
1565-
await new Promise(resolve => setTimeout(resolve, 20000));
1566-
}).timeout(30000);
15671533
});

0 commit comments

Comments
 (0)